JavaWeb课程设计客户信息管理系统_第1页
JavaWeb课程设计客户信息管理系统_第2页
JavaWeb课程设计客户信息管理系统_第3页
JavaWeb课程设计客户信息管理系统_第4页
JavaWeb课程设计客户信息管理系统_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 xxxx信息科学与工程学院 课程设计题 目: 客户信息管理系统 姓 名: xxxx 学 号: xxxx 班 级: xxxx 课 程: java web 任课教师 xxxx 2014年6月20日课程设计任务书及成绩评定题 目 客户信息管理系统课程设计的任务及要求 利用web应用程序的客户端开发技术(包括jsp、html、css、javascript、html、xml、mysql等)设计一个符合要求的java web数据库应用系统,并实现用户交互功能的设计,达到java web应用程序可用性和易用性目标。 课程设计所需的软件、硬件等 windows7,eclispe,jdk1.7,tomcat7

2、.0,mysql5.5设计报告:1、设计目的和任务2、总体设计:包括程序设计组成框图、流程图。3、详细设计:包括模块功能说明:函数功能、入口及出口参数说明,函数调用关系描述等。4、调试与测试:包括调试方法,测试结果分析与讨论,测试过程中遇到的主要问题及采取的解决措施。5、源程序清单和执行结果:清单中应有足够的注释。任课教师评语 成绩: 教师签名: 日期: 目录1.课程设计目的12.系统设计12.1系统特点12.2功能设计13.数据库设计14.功能模块的详细设计24.1数据库访问模块24.2共通servlet的处理34.3登录模块64.4客户资料录入74.5客户资料修改94.6客户资料删除115

3、.课程设计总结141.课程设计目的 课程设计是一项重要的实践性教学环节,在教师的指导下,以学生为中心,充分调动学生的积极性和能动性,重视学生自学能力的培养。 通过本课程设计可以使学生充分认识开发和设计web应用程序的的重要性和复杂性,充分了解web应用程序的设计和开发的基本过程,掌握常用的web开发技术,充分把握各项技术的特点和应用领域以及各项技术之间的相互关系,进一步体会各项技术在web应用程序中地位和作用从而对各种技术有比较清醒的认识,在此基础上习得web开发技术平台的选择能力。2.系统设计2.1系统特点 本系统尝试从一些简单的层面对于企业客户信息的管理进行一种探索,针对企业和客户的交流行

4、为进行系统化管理,力求做到客户信息的准确、快捷和可追溯性。本系统包括3个主要层面,客户信息维护、客户来电记录和客户回访记录。2.2功能设计(1)客户资料信息维护模块 客户信息输入、修改和删除。(2)客户来电信息模块 来电信息添加和来电信息查询。(3)客户回访信息模块 回访信息添加和回访信息查询。3.数据库设计(1)用户表user(2)客户信息表customer(3)客户来电表 incomecall4.功能模块的详细设计4.1数据库访问模块 数据库的设计是需要针对每个模块而不是每个页面进行设置数据库模块,所有的数据访问类duser、dincome、dcustomer、dfeedback、drem

5、ind从同一个父类dcommom继承,该父类提供了一个方法getdbconnection来获取数据库的链接。dcommon代码public class dcommon public connection getdbconnection( ) /尝试连接数据库 try /载入mysql的jdbc驱动类 class.forname(commonconst.db_driver_classname); connectionconn=drivermanager.getconnection ( commonconst.db_conn_string );/获得数据库连接 return conn; catch

6、(exception ex) ex.printstacktrace(); return null; 4.2共通servlet的处理 本系统中一旦代码出现了异常,将直接向上抛出,一直抛到共通类servlet进行处理。在共通servlet中发现异常,将页面跳转到错误处理页面,并把错误信息在页面上显示出来,同时提供一个往登录页面迁移的链接。对应的共通servlet的相关代码如下:public class commonservlet extends httpservlet /保存各页面id对应的action类的对象 private hashtable hpagehandler = new hashta

7、ble(); /配置文件的存放位置 private jxpathcontext configcontext = null; public void init() /取得配置文件,并获得其中的dom元素 string filepath = getinitparameter(configxml); string filerealpath = getservletcontext().getrealpath(filepath); /尝试建立配置文件的dom try org.jdom.input.saxbuilder builder = new saxbuilder(); org.jdom.docume

8、nt pdoc = builder.build(filerealpath ); configcontext = jxpathcontext.newcontext(pdoc); globalobjectprovider.init( configcontext ); catch(exception e) system.out.println(servlet初始化失败!); /初始化共通类以获取页面信息 commonconst.init(); /每一种动作第一次执行的时候,初始化对应的类 public void dopost ( httpservletrequest request, httpser

9、vletresponse response ) throws servletexception, ioexception /设置提交表单的中文编码 request.setcharacterencoding(gbk); httpsession mysession = request.getsession(true); /得到用户输入信息 string spageid = request.getparameter(pageid); string sactionid = request.getparameter(actionid); if ( spageid = null | spageid.equ

10、als() | sactionid = null | sactionid.equals() ) /非法进入页面,跳转到首页 mysession.invalidate(); response.sendredirect(./login.jsp); return; /如果非法进入页面(登录页面除外) if ( !spageid.equals(s001) & mysession.getattribute(loginuser) = null ) /非法进入页面,跳转到首页 mysession.invalidate(); response.sendredirect(./login.jsp); return

11、; try /根据pageid获得处理对象,如果没有则创建一个对象 object oactionobject = hpagehandler.get( spageid ); if ( oactionobject = null ) /根据配置文件创建一个新对象 string sclassname = (string)configcontext.getvalue( ch08-config/pageid=+spageid+/classname); oactionobject = class.forname( sclassname ).newinstance(); hpagehandler.put( s

12、pageid, oactionobject); /取得方法名 string smethodname = (string)configcontext.getvalue( ch08-config/pageid=+spageid+/actionid=+sactionid+/methodname); /生成对应的参数,并调用对应对象的对应方法 /inputdata是根据传入的参数做成的 hashtable inputdata = new hashtable(); enumeration params = request.getparameternames(); while( params.hasmor

13、eelements() string sparaname = (string)params.nextelement(); inputdata.put( sparaname, request.getparameter(sparaname) ); /outputdata是下一个页面的值域,在此只是被初始化 hashtable outputdata = new hashtable(); /生成参数列表 class paratype = class.forname(java.util.hashtable), class.forname(java.util.hashtable), class.forna

14、me(javax.servlet.http.httpsession) ; object paraobj = inputdata, outputdata, mysession ; /生成method对象 method invokemethod = oactionobject.getclass().getmethod( smethodname, paratype ); /调用方法 invokemethod.invoke( oactionobject, paraobj ); /根据outputdata的结果决定下一个页面 string snextpageid = (string)outputdata

15、.get(pageid); string srealpagepath = (string)configcontext.getvalue( ch08-config/pageid=+snextpageid+/path); /设置下一个页面的值域 mysession.setattribute( snextpageid, outputdata ); response.sendredirect( srealpagepath ); return; catch(exception e) /页面处理出错,跳转到错误处理页面 e.printstacktrace(); hashtable outputdata =

16、 new hashtable(); outputdata.put( exception, e ); /设置错误页面的值域 mysession.setattribute( commonconst.viewid_error, outputdata ); response.sendredirect(./error.jsp); return; public void doget ( httpservletrequest request, httpservletresponse response ) throws servletexception, ioexception dopost( request

17、, response ); 4.3登录模块 由于本系统用户角色只有一种,不存在跳转到不同页面的问题,处理相对简单一些,如果用户登录成功,则将用户信息放到session中,并将页面跳转到导航页面。(1)登录页面控制模块alogin相关代码如下:public class alogin public void dologin ( hashtable inputdata, hashtable outputdata, httpsession mysession ) throws exception /获取输入信息 string susername = (string)inputdata.get(user

18、name); string spassword = (string)inputdata.get(password); /校验用户输入信息 luser luser = (luser)globalobjectprovider.getlogicservice(commonconst.logic_key_user); /如果对应的类没有的话,报错并返回login页面 if ( luser = null ) throw new exception(发生了内部错误,请联系技术人员! ); /获取用户信息 user userinfo = luser.getuserinfo( susername, spass

19、word ); if ( userinfo = null ) outputdata.put( pageid, commonconst.viewid_login ); outputdata.put( errmsg, 用户名密码检查失败!请重新输入。 ); outputdata.put( username, susername ); return; else outputdata.put( pageid, commonconst.viewid_menu); /往session中设置用户信息 mysession.setattribute( loginuser, userinfo ); return;

20、 (2)登录效果图4.4客户资料录入 单击导航页面链接进入客户资料录入页面。注意两个方面:一是页面对应的显示元素和输入元素的颜色和当前模块的颜色想吻合,而是在用户输入信息并单击“登录”按钮时,将客户信息登入数据库,然后页面直接转入修改一览。页面控制类acustomeradd:public class acustomeradd /追加一个客户 public void doregister( hashtable inputdata, hashtable outputdata, httpsession mysession ) throws exception /首先获得要追加的客户详细信息 stri

21、ng srealname = (string)inputdata.get(realname); string ssex = (string)inputdata.get(sex); string sbirthday = (string)inputdata.get(birthday); string sphone = (string)inputdata.get(phone); string scellphone = (string)inputdata.get(cellphone); string saddress = (string)inputdata.get(address); string s

22、startdate = (string)inputdata.get(startdate); string smemo = (string)inputdata.get(memo); /生成一个customer对象以调用 customer customer = new customer(); customer.setrealname( srealname ); customer.setsex( ssex ); customer.setbirthday( sbirthday ); customer.setphone( sphone ); customer.setcellphone( scellpho

23、ne ); customer.setaddress( saddress ); customer.setstartdate( sstartdate ); customer.setmemo( smemo ); /调用对应的logic类 lcustomer lcustomer = (lcustomer)globalobjectprovider.getlogicservice(commonconst.logic_key_customer); /添加对应的记录 lcustomer.addcustomer( customer ); /然后重新检索,并将页面迁移到一览页面 vector vcustomers

24、 = lcustomer.getallcustomer(); outputdata.put( pageid, commonconst.viewid_customer_list); /往值域中设置当前位置信息 mysession.setattribute(customers, vcustomers ); outputdata.put( pageindex, new integer(0) ); return; 效果图:4.5客户资料修改public class acustomermodify /修改一个客户信息 public void doregister( hashtable inputdata

25、, hashtable outputdata, httpsession mysession ) throws exception /首先获得要修改的客户详细信息 string scustomerid = (string)inputdata.get(customerid); string srealname = (string)inputdata.get(realname); string ssex = (string)inputdata.get(sex); string sbirthday = (string)inputdata.get(birthday); string sphone = (

26、string)inputdata.get(phone); string scellphone = (string)inputdata.get(cellphone); string saddress = (string)inputdata.get(address); string sstartdate = (string)inputdata.get(startdate); string smemo = (string)inputdata.get(memo); /生成一个customer对象以调用 customer customer = new customer(); customer.setcu

27、stomerid( scustomerid ); customer.setrealname( srealname ); customer.setsex( ssex ); customer.setbirthday( sbirthday ); customer.setphone( sphone ); customer.setcellphone( scellphone ); customer.setaddress( saddress ); customer.setstartdate( sstartdate ); customer.setmemo( smemo ); /调用对应的logic类 lcus

28、tomer lcustomer = (lcustomer)globalobjectprovider.getlogicservice(commonconst.logic_key_customer); /添加对应的记录 lcustomer.modifycustomer( customer ); /然后重新检索,并将页面迁移到一览页面 vector vcustomers = lcustomer.getallcustomer(); outputdata.put( pageid, commonconst.viewid_customer_list); /往值域中设置当前位置信息 mysession.set

29、attribute(customers, vcustomers ); outputdata.put( pageindex, new integer(0) ); return; 4.6客户资料删除public class acustomerdelete /到首页 public void dofirst( hashtable inputdata, hashtable outputdata, httpsession mysession ) throws exception /首页的index一定为0 outputdata.put( pageid, commonconst.viewid_custome

30、r_delete); /往值域中设置当前位置信息 outputdata.put( pageindex, new integer(0) ); return; /到末页 public void dolast( hashtable inputdata, hashtable outputdata, httpsession mysession ) throws exception /首先获得全部客户信息,并计算出最后一页的位置 vector allcustomers = (vector)mysession.getattribute(customers); int imax = allcustomers.

31、size(); int imaxpage = (int)math.ceil(double)imax/20); int iindex = (imaxpage-1)*20; /首页的index一定为0 outputdata.put( pageid, commonconst.viewid_customer_delete); /往值域中设置当前位置信息 outputdata.put( pageindex, new integer(iindex) ); return; /到前页 public void doprev( hashtable inputdata, hashtable outputdata,

32、httpsession mysession ) throws exception /首先获得当前页 string scurpage = (string)inputdata.get(curpage); int icurpage = (new integer(scurpage).intvalue(); int iindex = (icurpage-2)*20; outputdata.put( pageid, commonconst.viewid_customer_delete); /往值域中设置当前位置信息 outputdata.put( pageindex, new integer(iindex

33、) ); return; /到次页 public void donext( hashtable inputdata, hashtable outputdata, httpsession mysession ) throws exception /首先获得当前页 string scurpage = (string)inputdata.get(curpage); int icurpage = (new integer(scurpage).intvalue(); int iindex = icurpage*20; outputdata.put( pageid, commonconst.viewid_

34、customer_delete); /往值域中设置当前位置信息 outputdata.put( pageindex, new integer(iindex) ); return; /到首页 public void dospec( hashtable inputdata, hashtable outputdata, httpsession mysession ) throws exception /首先获得指定页码 string sspecpage = (string)inputdata.get(spec); /获得全部客户信息,并计算出最后一页的位置 vector allcustomers =

35、 (vector)mysession.getattribute(customers); int imax = allcustomers.size(); int imaxpage = (int)math.ceil(double)imax/20); int ispec = (new integer(sspecpage).intvalue(); /如果指定页大于全部页码,则跳转到第一页 if ( ispec imaxpage ) ispec = 1; /指定页 outputdata.put( pageid, commonconst.viewid_customer_delete); /往值域中设置当前位置信息 outputdata.put( pageindex, new integer(ispec-1)*20) )

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论