JavaWeb课程设计客户信息管理系统.doc

上传人:土8路 文档编号:10301736 上传时间:2021-05-07 格式:DOC 页数:17 大小:223KB
返回 下载 相关 举报
JavaWeb课程设计客户信息管理系统.doc_第1页
第1页 / 共17页
JavaWeb课程设计客户信息管理系统.doc_第2页
第2页 / 共17页
JavaWeb课程设计客户信息管理系统.doc_第3页
第3页 / 共17页
JavaWeb课程设计客户信息管理系统.doc_第4页
第4页 / 共17页
JavaWeb课程设计客户信息管理系统.doc_第5页
第5页 / 共17页
点击查看更多>>
资源描述

《JavaWeb课程设计客户信息管理系统.doc》由会员分享,可在线阅读,更多相关《JavaWeb课程设计客户信息管理系统.doc(17页珍藏版)》请在三一文库上搜索。

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 = (Vector)mySession.getAttribute(customers); int iMa

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1