JavaWeb课程设计Word文档下载推荐.docx
- 文档编号:22056723
- 上传时间:2023-02-02
- 格式:DOCX
- 页数:41
- 大小:1.81MB
JavaWeb课程设计Word文档下载推荐.docx
《JavaWeb课程设计Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《JavaWeb课程设计Word文档下载推荐.docx(41页珍藏版)》请在冰豆网上搜索。
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代码
publicclassDCommon
{
publicConnectiongetDBConnection()
{//尝试连接数据库
try
{//载入MySQL的JDBC驱动类
Class.forName(CommonConst.DB_DRIVER_CLASSNAME);
Connectionconn=DriverManager.getConnection
(CommonConst.DB_CONN_STRING);
//获得数据库连接
returnconn;
}
catch(Exceptionex)
{
ex.printStackTrace();
returnnull;
}
3、共通Servlet的处理
本系统中一旦代码出现了异常,将直接向上抛出,一直抛到共通类Servlet进行处理。
在共通Servlet中发现异常,将页面跳转到错误处理页面,并把错误信息在页面上显示出来,同时提供一个往登录页面迁移的链接。
对应的共通Servlet的相关代码如下:
publicclassCommonServletextendsHttpServlet
//保存各页面Id对应的action类的对象
privateHashtablehPageHandler=newHashtable();
//配置文件的存放位置
privateJXPathContextconfigContext=null;
publicvoidinit()
//取得配置文件,并获得其中的dom元素
StringfilePath=getInitParameter("
configXML"
);
StringfileRealPath=getServletContext().getRealPath(filePath);
//尝试建立配置文件的DOM
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)
//根据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(
]/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("
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("
StringsRealPagePath=(String)configContext.getValue(
+sNextPageId+"
]/@path"
//设置下一个页面的值域
mySession.setAttribute(sNextPageId,outputData);
response.sendRedirect(sRealPagePath);
//页面处理出错,跳转到错误处理页面
e.printStackTrace();
outputData.put("
exception"
e);
//设置错误页面的值域
mySession.setAttribute(CommonConst.VIEWID_ERROR,outputData);
../error.jsp"
publicvoiddoGet(HttpServletRequestrequest,
doPost(request,response);
错误页面:
4、登录模块
由于本系统用户角色只有一种,不存在跳转到不同页面的问题,处理相对简单一些,如果用户登录成功,则将用户信息放到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)
CommonConst.VIEWID_LOGIN);
errMsg"
"
用户名密码检查失败!
请重新输入。
sUsername);
else
{
CommonConst.VIEWID_MENU);
//往session中设置用户信息
mySession.setAttribute("
userInfo);
(2)登录效果图
5、页面导航设计
(1)页面位置信息和页面的pageid息息相关,考虑用一个全局变量来存这个信息,然后通过在共通文件中来访问这个全局变量来获取对应页面的名称。
为了达到这个目的设置一个成员变量pageinfo和对应的设置方法init(),对应代码如下:
publicstaticHashtablepageInfos=newHashtable();
//数据库相关常量
publicstaticStringDB_DRIVER_CLASSNAME="
com.mysql.jdbc.Driver"
;
publicstaticStringDB_CONN_STRING="
jdbc:
mysql:
//localhost/ch08?
user=root&
password=123"
//初始化
publicstaticvoidinit()
pageInfos.put("
S002"
"
目录页面"
S110"
客户资料>
客户资料录入页面"
S120"
客户资料修改一览页面"
S121"
客户资料修改详细页面"
S130"
客户资料删除页面"
S210"
客户来电>
快速反应条件输入页面"
S211"
快速反应结果一览页面"
S220"
客户来电信息添加页面"
S230"
客户来电信息查找页面"
S231"
客户来电信息一览页面"
S232"
客户来电信息详细页面"
S310"
客户回访>
客户回访信息添加页面"
S320"
客户回访信息查找页面"
S321"
客户回访信息一览页面"
S322"
客户回访信息详细页面"
S410"
客户重要信息提醒页面"
//获得页面信息
publicstaticStringgetPageInfo(StringsPageId)
return(String)pageInfos.get(sPageId);
(2)页面外观设计
为四个模块设计不同颜色风格的CSS代码
.tr_head1{color:
black;
background-color:
#aaccaa;
.tr_content1{color:
#eeffee;
cursor:
hand;
.tr_head2{color:
#ccaaaa;
.tr_content2{color:
#ffeeee;
.tr_head3{color:
#aaaacc;
.tr_content3{color:
#eeeeff;
.tr_head4{color:
#ccccaa;
.tr_content4{color:
#ffffee;
(3)导航页效果图
5、客户资料维护模块
(1)客户资料录入
单击导航页面链接进入客户资料录入页面。
注意两个方面:
一是页面对应的显示元素和输入元素的颜色和当前模块的颜色想吻合,而是在用户输入信息并单击“登录”按钮时,将客户信息登入数据库,然后页面直接转入修改一览。
页面控制类ACustomerAdd:
publicclassACustomerAdd
//追加一个客户
publicvoiddoRegister(HashtableinputData,
//首先获得要追加的客户详细信息
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(cus
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JavaWeb 课程设计
![提示](https://static.bdocx.com/images/bang_tan.gif)