xxxx
信息科学与工程学院 课程设计
题 目: 客户信息管理系统
姓 名: xxxx
学 号: xxxx
班 级: xxxx
课 程: Java Web
任课教师 xxxx
20**年6月20日
课程设计任务书及成绩评定
目录
1.课程设计目的 1
2.系统设计 1
2.1系统特点 1
2.2功能设计 1
3.数据库设计 1
4.功能模块的详细设计 2
4.1数据库访问模块 2
4.2共通Servlet的处理 3
4.3登录模块 6
4.4客户资料录入 7
4.5客户资料修改 9
4.6客户资料删除 11
5.课程设计总结 14
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代码
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(Exception ex)
{
ex.printStackTrace();
return null;
}
}
}
4.2共通Servlet的处理
本系统中一旦代码出现了异常,将直接向上抛出,一直抛到共通类Servlet进行处理。
在共通Servlet中发现异常,将页面跳转到错误处理页面,并把错误信息在页面上显示出来,同时提供一个往登录页面迁移的链接。
对应的共通Servlet的相关代码如下:
public class CommonServlet extends HttpServlet
{
//保存各页面Id对应的action类的对象
private Hashtable hPageHandler = new Hashtable();
//配置文件的存放位置
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.Document 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,
HttpServletResponse 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.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获得处理对象,如果没有则创建一个对象
Object oActionObject = hPageHandler.get( sPageId );
if ( oActionObject == null )
{
//根据配置文件创建一个新对象
String sClassName = (String)configContext.getValue(
"ch08-config/page[@id='"+sPageId+"']/@className");
oActionObject = Class.forName( sClassName ).newInstance();
hPageHandler.put( sPageId, oActionObject);
}
//取得方法名
String sMethodName = (String)configContext.getValue(
"ch08-config/page[@id='"+sPageId+"']/action[@id='"+sActionId+"']/@methodName");
//生成对应的参数,并调用对应对象的对应方法
//inputData是根据传入的参数做成的
Hashtable inputData = new Hashtable();
Enumeration params = request.getParameterNames();
while( params.hasMoreElements())
{
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.forName("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.get("pageId");
String sRealPagePath = (String)configContext.getValue(
"ch08-config/page[@id='"+sNextPageId+"']/@path");
//设置下一个页面的值域
mySession.setAttribute( sNextPageId, outputData );
response.sendRedirect( sRealPagePath );
return;
}
catch(Exception e)
{
//页面处理出错,跳转到错误处理页面
e.printStackTrace();
Hashtable outputData = 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, 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("username");
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, 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:
public class ACustomerAdd
{
//追加一个客户
public void doRegister( Hashtable inputData,
Hashtable outputData,
HttpSession mySession )
throws Exception
{
//首先获得要追加的客户详细信息
String 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 sStartDate = (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( sCellphone );
customer.setAddress( sAddress );
customer.setStartDate( sStartDate );
customer.setMemo( sMemo );
//调用对应的logic类
LCustomer lCustomer = (LCustomer)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_CUSTOMER);
//添加对应的记录
lCustomer.addCustomer( customer );
//然后重新检索,并将页面迁移到一览页面
Vector vCustomers = 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,
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 = (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.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类
LCustomer lCustomer = (LCustomer)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_CUSTOMER);
//添加对应的记录
lCustomer.modifyCustomer( customer );
//然后重新检索,并将页面迁移到一览页面
Vector vCustomers = lCustomer.getAllCustomer();
outputData.put( "pageId", CommonConst.VIEWID_CUSTOMER_LIST);
//往值域中设置当前位置信息
mySession.setAttribute("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_CUSTOMER_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.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,
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) );
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_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 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) );
return;
}
//修改某条记录
public void doDelete( Hashtable inputData,
Hashtable outputData,
HttpSession mySession )
throws Exception
{
//首先获得要修改的客户ID
String sCustomerId = (String)inputData.get("customerId");
//获得对应的客户的详细信息,然后迁移到客户详细信息修改页面
//调用对应的logic类
LCustomer lCustomer = (LCustomer)GlobalObjectProvider.getLogicService(CommonConst.LOGIC_KEY_CUSTOMER);
//删除对应的记录
lCustomer.deleteCustomerById( sCustomerId );
//然后重新检索,并定位到第一页
Vector vCustomers = lCustomer.getAllCustomer();
//由于需要在页面迁移中使用题库,所以放到session中
mySession.setAttribute( "customers", vCustomers );
//然后迁移到指定页面
outputData.put( "pageId", CommonConst.VIEWID_CUSTOMER_DELETE);
//往值域中设置当前位置信息
outputData.put( "pageIndex", new Integer(0) );
return;
}
}
5.课程设计总结
MVC模块划分、内容结构如何组织的方法,对一个Web程序设计的影响是很大的,有效的规划可以为Web程序设计增加美感。其它的模块则有一定的联系性。
但是所有的模板其并非是层级关系——即一层一层的点下去,他们可以通过导航栏上的链接转到其它WEB程序设计上,由此可形成一个具有Web程序设计的模式,因此这些模块之间可以实现无顺序关系,却仍能感受到该Web程序设计是一个很条理。美工方面做得还是差了些,以后会多下一番功夫。
我想这次项目的完成对我们有很大的帮助,不仅在JAVA语言的运用上有了提高,对于数据库语言及操作也有了比较全面深刻的了解,比如如何创建一个表,插入相应的字段,给字段添加相关的属性,以及对表进行相关的搜索。在服务器中的.xml文件配置方面也了解到了相应标签的含义以及如何配置,并上传到服务器上。在此次项目中,对有关制作WEB项目的软件比如Tomcat、MyEclipse等软件的运用上也有了小幅的提高。综合一上,这次web项目的制作对我在综合运用方面有了很大的帮助提高。
参考文献:
[1] 沈应逵. Java Web数据库系统应用开发与实例.北京:人民邮电出版社,2009
课程设计课程名称JAVAEENET课程设计设计题目校园超市商品信息管理系统学院信息工程与自动化学院专业计算机科学与技术年级20xx…
桂电编号基于J2EE的开发技术课程设计报告题目桂林市一零八医院导航网站系别计算机科学与工程学院专业信息管理与信息系统学生姓名学号指…
JavaEE与中间件课程设计任务书辽宁工程技术大学软件学院软件工程系一设计目的JavaEE课程设计是对所学JavaEE与中间件课程…
软件综合课程设计报告题目名称在线员工信息管理班级计0813学生学号20xx25501322学生姓名王绍辉同组学生学号同组学生姓名指…
河北科技大学课程设计报告学生姓名祝冬冬学号专业班级计算机科学与技术课程名称学年学期指导教师2011年6月课程设计成绩评定表目录示例…
沈阳理工大学课程实践论文目录1前言111作业背景112课题简介113工作介绍1131个人主要工作1132主要收获2133自我评定2…
Java课程设计报告课目计算器学院基础学院班级光信息20xx1学生指导教师丁振凡张晓瑞辅导教师江宇完成时间20xx年7月1日课程设…
Flash程序设计课程设计报告课程名称Flash程序设计实验项目名称4屏flash焦点图上下切换效果程序院系物理与电子信息学院学号…
20xx20xx学年第1学期滨州学院JavaWeb开发与应用课程设计报告题专班姓目齐鲁软件大赛报名系统的设计业计算机网络技术级20…
湖南科技大学计算机科学与工程学院WEB应用开发课程设计报告学号1105010113姓名罗孜专业班指导老师韩雪博研图书管理系统一摘要…
关于Javaweb课程设计的心得体会----在线测试系统这次课程设计我做的是章节自测系统,主要是服务于学生进行阶段性自测和练习。系…