JavaWeb课程设计客户信息管理系统.docx
《JavaWeb课程设计客户信息管理系统.docx》由会员分享,可在线阅读,更多相关《JavaWeb课程设计客户信息管理系统.docx(20页珍藏版)》请在冰豆网上搜索。
JavaWeb课程设计客户信息管理系统
xxxx
信息科学与工程学院课程设计
题目:
客户信息管理系统
姓名:
xxxx
学号:
xxxx
班级:
xxxx
课程:
JavaWeb
任课教师xxxx
2014年6月20日
课程设计任务书及成绩评定
题目
客户信息管理系统
课程设计的任务及要求
利用Web应用程序的客户端开发技术(包括Jsp、HTML、CSS、JavaScript、HTML、XML、MySql等)设计一个符合要求的JavaWeb数据库应用系统,并实现用户交互功能的设计,达到JavaWeb应用程序可用性和易用性目标。
课程设计所需的软件、硬件等
windows7,eclispe,jdk1.7,tomcat7.0,mysql5.5
设计报告:
1、设计目的和任务
2、总体设计:
包括程序设计组成框图、流程图。
3、详细设计:
包括模块功能说明:
函数功能、入口及出口参数说明,函数调用关系描述等。
4、调试与测试:
包括调试方法,测试结果分析与讨论,测试过程中遇到的主要问题及采取的解决措施。
5、源程序清单和执行结果:
清单中应有足够的注释。
任课教师评语
成绩:
教师签名:
日期:
1.课程设计目的
课程设计是一项重要的实践性教学环节,在教师的指导下,以学生为中心,充分调动学生的积极性和能动性,重视学生自学能力的培养。
通过本课程设计可以使学生充分认识开发和设计Web应用程序的的重要性和复杂性,充分了解Web应用程序的设计和开发的基本过程,掌握常用的Web开发技术,充分把握各项技术的特点和应用领域以及各项技术之间的相互关系,进一步体会各项技术在Web应用程序中地位和作用从而对各种技术有比较清醒的认识,在此基础上习得Web开发技术平台的选择能力。
2.系统设计
2.1系统特点
本系统尝试从一些简单的层面对于企业客户信息的管理进行一种探索,针对企业和客户的交流行为进行系统化管理,力求做到客户信息的准确、快捷和可追溯性。
本系统包括3个主要层面,客户信息维护、客户来电记录和客户回访记录。
2.2功能设计
(1)客户资料信息维护模块
客户信息输入、修改和删除。
(2)客户来电信息模块
来电信息添加和来电信息查询。
(3)客户回访信息模块
回访信息添加和回访信息查询。
3.数据库设计
(1)用户表user
(2)客户信息表Customer
(3)客户来电表IncomeCall
4.功能模块的详细设计
4.1数据库访问模块
数据库的设计是需要针对每个模块而不是每个页面进行设置数据库模块,所有的数据访问类DUser、DIncome、Dcustomer、DFeedback、DRemind从同一个父类Dcommom继承,该父类提供了一个方法getDBConnection来获取数据库的链接。
DCommon代码
publicclassDCommon
{
publicConnectiongetDBConnection()
{//尝试连接数据库
try
{//载入MySQL的JDBC驱动类
Class.forName(CommonConst.DB_DRIVER_CLASSNAME);
Connectionconn=DriverManager.getConnection
(CommonConst.DB_CONN_STRING);//获得数据库连接
returnconn;
}
catch(Exceptionex)
{
ex.printStackTrace();
returnnull;
}
}
}
4.2共通Servlet的处理
本系统中一旦代码出现了异常,将直接向上抛出,一直抛到共通类Servlet进行处理。
在共通Servlet中发现异常,将页面跳转到错误处理页面,并把错误信息在页面上显示出来,同时提供一个往登录页面迁移的链接。
对应的共通Servlet的相关代码如下:
publicclassCommonServletextendsHttpServlet
{
//保存各页面Id对应的action类的对象
privateHashtablehPageHandler=newHashtable();
//配置文件的存放位置
privateJXPathContextconfigContext=null;
publicvoidinit()
{
//取得配置文件,并获得其中的dom元素
StringfilePath=getInitParameter("configXML");
StringfileRealPath=getServletContext().getRealPath(filePath);
//尝试建立配置文件的DOM
try
{
org.jdom.input.SAXBuilderbuilder=newSAXBuilder();
org.jdom.DocumentpDoc=builder.build(fileRealPath);
configContext=JXPathContext.newContext(pDoc);
GlobalObjectProvider.init(configContext);
}
catch(Exceptione)
{
System.out.println("Servlet初始化失败!
");
}
//初始化共通类以获取页面信息
CommonConst.init();
}
//每一种动作第一次执行的时候,初始化对应的类
publicvoiddoPost(HttpServletRequestrequest,
HttpServletResponseresponse)
throwsServletException,IOException
{
//设置提交表单的中文编码
request.setCharacterEncoding("GBK");
HttpSessionmySession=request.getSession(true);
//得到用户输入信息
StringsPageId=request.getParameter("pageId");
StringsActionId=request.getParameter("actionId");
if(sPageId==null||sPageId.equals("")
||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;
}
try
{
//根据pageId获得处理对象,如果没有则创建一个对象
ObjectoActionObject=hPageHandler.get(sPageId);
if(oActionObject==null)
{
//根据配置文件创建一个新对象
StringsClassName=(String)configContext.getValue(
"ch08-config/page[@id='"+sPageId+"']/@className");
oActionObject=Class.forName(sClassName).newInstance();
hPageHandler.put(sPageId,oActionObject);
}
//取得方法名
StringsMethodName=(String)configContext.getValue(
"ch08-config/page[@id='"+sPageId+"']/action[@id='"+sActionId+"']/@methodName");
//生成对应的参数,并调用对应对象的对应方法
//inputData是根据传入的参数做成的
HashtableinputData=newHashtable();
Enumerationparams=request.getParameterNames();
while(params.hasMoreElements())
{
StringsParaName=(String)params.nextElement();
inputData.put(sParaName,request.getParameter(sParaName));
}
//outputData是下一个页面的值域,在此只是被初始化
HashtableoutputData=newHashtable();
//生成参数列表
Class[]paraType={Class.forName("java.util.Hashtable"),
Class.forName("java.util.Hashtable"),
Class.forName("javax.servlet.http.HttpSession")};
Object[]paraObj={inputData,outputData,mySession};
//生成Method对象
MethodinvokeMethod=oActionObject.getClass().getMethod(sMethodName,paraType);
//调用方法
invokeMethod.invoke(oActionObject,paraObj);
//根据outputData的结果决定下一个页面
StringsNextPageId=(String)outputData.get("pageId");
StringsRealPagePath=(String)configContext.getValue(
"ch08-config/page[@id='"+sNextPageId+"']/@path");
//设置下一个页面的值域
mySession.setAttribute(sNextPageId,outputData);
response.sendRedirect(sRealPagePath);
return;
}
catch(Exceptione)
{
//页面处理出错,跳转到错误处理页面
e.printStackTrace();
HashtableoutputData=newHashtable();
outputData.put("exception",e);
//设置错误页面的值域
mySession.setAttribute(CommonConst.VIEWID_ERROR,outputData);
response.sendRedirect("../error.jsp");
return;
}
}
publicvoiddoGet(HttpServletRequestrequest,
HttpServletResponseresponse)
throwsServletException,IOException
{
doPost(request,response);
}
}
4.3登录模块
由于本系统用户角色只有一种,不存在跳转到不同页面的问题,处理相对简单一些,如果用户登录成功,则将用户信息放到session中,并将页面跳转到导航页面。
(1)登录页面控制模块ALogin相关代码如下:
publicclassALogin
{
publicvoiddoLogin(HashtableinputData,
HashtableoutputData,
HttpSessionmySession)
throwsException
{
//获取输入信息
StringsUsername=(String)inputData.get("username");
StringsPassword=(String)inputData.get("password");
//校验用户输入信息
LUserlUser=(LUser)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_USER);
//如果对应的类没有的话,报错并返回login页面
if(lUser==null)
{
thrownewException("发生了内部错误,请联系技术人员!
");
}
//获取用户信息
UseruserInfo=lUser.getUserInfo(sUsername,sPassword);
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;
}
}
}
(2)登录效果图
4.4客户资料录入
单击导航页面链接进入客户资料录入页面。
注意两个方面:
一是页面对应的显示元素和输入元素的颜色和当前模块的颜色想吻合,而是在用户输入信息并单击“登录”按钮时,将客户信息登入数据库,然后页面直接转入修改一览。
页面控制类ACustomerAdd:
publicclassACustomerAdd
{
//追加一个客户
publicvoiddoRegister(HashtableinputData,
HashtableoutputData,
HttpSessionmySession)
throwsException
{
//首先获得要追加的客户详细信息
StringsRealname=(String)inputData.get("realname");
StringsSex=(String)inputData.get("sex");
StringsBirthday=(String)inputData.get("birthday");
StringsPhone=(String)inputData.get("phone");
StringsCellphone=(String)inputData.get("cellphone");
StringsAddress=(String)inputData.get("address");
StringsStartDate=(String)inputData.get("startDate");
StringsMemo=(String)inputData.get("memo");
//生成一个Customer对象以调用
Customercustomer=newCustomer();
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类
LCustomerlCustomer=(LCustomer)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_CUSTOMER);
//添加对应的记录
lCustomer.addCustomer(customer);
//然后重新检索,并将页面迁移到一览页面
VectorvCustomers=lCustomer.getAllCustomer();
outputData.put("pageId",CommonConst.VIEWID_CUSTOMER_LIST);
//往值域中设置当前位置信息
mySession.setAttribute("customers",vCustomers);
outputData.put("pageIndex",newInteger(0));
return;
}
}
效果图:
4.5客户资料修改
publicclassACustomerModify
{
//修改一个客户信息
publicvoiddoRegister(HashtableinputData,
HashtableoutputData,
HttpSessionmySession)
throwsException
{
//首先获得要修改的客户详细信息
StringsCustomerId=(String)inputData.get("customerId");
StringsRealname=(String)inputData.get("realname");
StringsSex=(String)inputData.get("sex");
StringsBirthday=(String)inputData.get("birthday");
StringsPhone=(String)inputData.get("phone");
StringsCellphone=(String)inputData.get("cellphone");
StringsAddress=(String)inputData.get("address");
StringsStartDate=(String)inputData.get("startDate");
StringsMemo=(String)inputData.get("memo");
//生成一个Customer对象以调用
Customercustomer=newCustomer();
customer.setCustomerId(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类
LCustomerlCustomer=(LCustomer)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_CUSTOMER);
//添加对应的记录
lCustomer.modifyCustomer(customer);
//然后重新检索,并将页面迁移到一览页面
VectorvCustomers=lCustomer.getAllCustomer();
outputData.put("pageId",CommonConst.VIEWID_CUSTOMER_LIST);
//往值域中设置当前位置信息
mySession.setAttribute("customers",vCustomers);
outputData.put("pageIndex",newInteger(0));
return;
}
}
4.6客户资料删除
publicclassACustomerDelete
{
//到首页
publicvoiddoFirst(HashtableinputData,
HashtableoutputData,
HttpSessionmySession)
throwsException
{
//首页的index一定为0
outputData.put("pageId",CommonConst.VIEWID_CUSTOMER_DELETE);
//往值域中设置当前位置信息
outputData.put("pageIndex",newInteger(0));
return;
}
//到末页
publicvoiddoLast(HashtableinputData,
HashtableoutputData,
HttpSessionmySession)
throwsException
{
//首先获得全部客户信息,并计算出最后一页的位置
VectorallCustomers=(Vector)mySession.getA