资源描述
JavaWeb 课程设计
题目:用户信息管理系统
专 业:计算机科学和技术
年 级:计091—3
学 号:25501348
作 者:刘丹凤
指导老师:贺秉庚
完成时间:6月17日
目录
JavaWeb 课程设计 1
题目:用户信息管理系统 1
一.课程设计目标 4
二.课程设计内容和目标 5
三、 系统设计 6
1、 系统特点 6
2、 功效设计 6
3、 用户界面草图 7
4、 页面迁移图 9
5、 页面功效设计 9
四、 数据库设计 10
1、数据库表 10
2、数据库操作图 12
五、 功效模块具体设计 13
1、程序目录结构图 13
2、数据库访问模块 13
3、 共通Servlet处理 15
4、 登录模块 22
5、 页面导航设计 24
5、 用户资料维护模块 26
6、 用户来电信息模块 33
7、 用户回访信息模块 35
8、 用户关键信息提醒模块 36
六、 对本系统开发思索总结 39
七、 对软件开发方法体会 39
八、 自主创新申明 40
九、致谢 40
一.课程设计目标
课程设计是一项关键实践性教学步骤,在老师指导下,以学生为中心,充足调动学生主动性和能动性,重视学生自学能力培养。
《Java Web 数据库系统应用开发和实例》是为教育技术学本科专业开设专业选修课程,课程关键目标是要求学生掌握基础Web应用程序开发和设计步骤及相关技术技能。本课程在讲解相关理论知识基础上,根据一定组织标准和现有试验条件安排了一定数量试验,经过这些试验使学生初步掌握开发和设计Web数据库系统基础方法和基础技能。然而因为这些试验是分时分批按一定技术种类和试验目标实施,当然能够有目标地训练和培养学生某个方面技能,但显著不连续性使学生不能从整体上把握怎样系统地开发和设计一个完整Web数据库系统应用程序。经过本课程设计能够很好地处理这个问题。
经过本课程设计能够使学生充足认识开发和设计Web应用程序关键性和复杂性,充足了解Web应用程序设计和开发基础过程,掌握常见Web开发技术,充足把握各项技术特点和应用领域和各项技术之间相互关系,深入体会各项技术在Web应用程序中地位和作用从而对多种技术有比较清醒认识,在此基础上习得Web开发技术平台选择能力。
二.课程设计内容和目标
课题名称:用户信息管理系统
设计目标:本系统模拟企业对于用户信息管理,操作人员能够添加、修改用户信息,针对用户来电进行统计,并对用户关键信息进行提醒,等等。
设计方法:jsp、mysql动态网页制作工具配合相关技术(如HTML、CSS、JavaScript、xml等)
设计要求:利用Web应用程序用户端开发技术(包含Jsp、HTML、CSS、JavaScript、HTML、XML、MySql等)设计一个符合要求Java Web数据库应用系统,并实现用户交互功效设计,达成Java Web应用程序可用性和易用性目标。
开发模式:MVC模式。MVC模式目标就是实现Web系统职能分工。 Model层实现系统中业务逻辑,通常能够用JavaBean或EJB来实现。 View层用于和用户交互,通常见JSP来实现。 Controller层是Model和View之间沟通桥梁,它能够分配用户请求并选择合适视图以用于显示,同时它也能够解释用户输入并将它们映射为模型层可实施操作。
开发工具:windows7,eclispe,jdk1.7,tomcat7.0、mysql5.5
三、 系统设计
1、 系统特点
本系统尝试从部分简单层面对于企业用户信息管理进行一个探索,针对企业和用户交流行为进行系统化管理,努力争取做到用户信息正确、快捷和可追溯性。
本系统包含3个关键层面,用户信息维护、用户来电统计和用户回访统计。
2、 功效设计
4个模块
(1)用户资料信息维护模块
用户信息输入、修改和删除。
(2)用户来电信息模块
来电信息添加和来电信息查询。
(3)用户回访信息模块
回访信息添加和回访信息查询。
(4)用户关键信息提醒模块
用例图UseCase
3、 用户界面草图
登录草图
导航页面草图
其它功效见后面操作效果图
4、 页面迁移图
从页面迁移图中能够看出,本系统页面迁移基础上发生在模块内部,整体比较简单而清楚
5、 页面功效设计
全部页面pageId和对应页面Jsp文件名及所对应功效
四、 数据库设计
1、数据库表
(1)用户表user
(2)用户信息表Customer
(3)用户来电表 IncomeCall
(4)用户回访表 FeedBackCall
2、数据库操作图
五、 功效模块具体设计
1、程序目录结构图
2、数据库访问模块
数据库设计是需要针对每个模块而不是每个页面进行设置数据库模块,全部数据访问类DUser、DIncome、Dcustomer、DFeedback、DRemind从同一个父类Dcommom继承,该父类提供了一个方法getDBConnection来获取数据库链接。
DCommon代码
public class DCommon
{
public Connection getDBConnection( )
{//尝试连接数据库
try
{ //载入MySQLJDBC驱动类
Class.forName(CommonConst.DB_DRIVER_CLASSNAME);
Connectionconn=DriverManager.getConnection
( CommonConst.DB_CONN_STRING );//取得数据库连接
return conn;
}
catch(Exception ex)
{
ex.printStackTrace();
return null;
}
}
}
3、 共通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、 登录模块
因为本系统用户角色只有一个,不存在跳转到不一样页面问题,处理相对简单部分,假如用户登录成功,则将用户信息放到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) 登录效果图
5、 页面导航设计
(1)页面位置信息和页面pageid息息相关,考虑用一个全局变量来存这个信息,然后经过在共通文件中来访问这个全局变量来获取对应页面名称。为了达成这个目标设置一个组员变量pageinfo和对应设置方法init(),对应代码以下:
public static Hashtable pageInfos = new Hashtable();
//数据库相关常量
public static String DB_DRIVER_CLASSNAME = "com.mysql.jdbc.Driver";
public static String DB_CONN_STRING = "jdbc:mysql://localhost/ch08?user=root&password=123";
//初始化
public static void init()
{
pageInfos.put("S002","目录页面");
pageInfos.put("S110","用户资料 > 用户资料录入页面");
pageInfos.put("S120","用户资料 > 用户资料修改一览页面");
pageInfos.put("S121","用户资料 > 用户资料修改具体页面");
pageInfos.put("S130","用户资料 > 用户资料删除页面");
pageInfos.put("S210","用户来电 > 快速反应条件输入页面");
pageInfos.put("S211","用户来电 > 快速反应结果一览页面");
pageInfos.put("S220","用户来电 > 用户来电信息添加页面");
pageInfos.put("S230","用户来电 > 用户来电信息查找页面");
pageInfos.put("S231","用户来电 > 用户来电信息一览页面");
pageInfos.put("S232","用户来电 > 用户来电信息具体页面");
pageInfos.put("S310","用户回访 > 用户回访信息添加页面");
pageInfos.put("S320","用户回访 > 用户回访信息查找页面");
pageInfos.put("S321","用户回访 > 用户回访信息一览页面");
pageInfos.put("S322","用户回访 > 用户回访信息具体页面");
pageInfos.put("S410","用户关键信息提醒页面");
}
//取得页面信息
public static String getPageInfo( String sPageId )
{
return (String)pageInfos.get(sPageId);
}
(2) 页面外观设计
为四个模块设计不一样颜色风格CSS代码
.tr_head1 {color: black; background-color:#aaccaa;}
.tr_content1 {color: black; background-color:#eeffee; cursor:hand;}
.tr_head2 {color: black; background-color:#ccaaaa;}
.tr_content2 {color: black; background-color:#ffeeee; cursor:hand;}
.tr_head3 {color: black; background-color:#aaaacc;}
.tr_content3 {color: black; background-color:#eeeeff; cursor:hand;}
.tr_head4 {color: black; background-color:#ccccaa;}
.tr_content4 {color: black; background-color:#ffffee; cursor:hand;}
(3) 导航页效果图
5、 用户资料维护模块
(1) 用户资料录入
单击导航页面链接进入用户资料录入页面。注意两个方面:一是页面对应显示元素和输入元素颜色和目前模块颜色想吻合,而是在用户输入信息并单击“登录”按钮时,将用户信息登入数据库,然后页面直接转入修改一览。
页面控制类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;
}
}
效果图:
(2) 用户资料修改
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;
}
展开阅读全文