javaEE衡量生活质量课程设计报告.doc

上传人:b****9 文档编号:118333 上传时间:2022-10-03 格式:DOC 页数:16 大小:89.50KB
下载 相关 举报
javaEE衡量生活质量课程设计报告.doc_第1页
第1页 / 共16页
javaEE衡量生活质量课程设计报告.doc_第2页
第2页 / 共16页
javaEE衡量生活质量课程设计报告.doc_第3页
第3页 / 共16页
javaEE衡量生活质量课程设计报告.doc_第4页
第4页 / 共16页
javaEE衡量生活质量课程设计报告.doc_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

javaEE衡量生活质量课程设计报告.doc

《javaEE衡量生活质量课程设计报告.doc》由会员分享,可在线阅读,更多相关《javaEE衡量生活质量课程设计报告.doc(16页珍藏版)》请在冰豆网上搜索。

javaEE衡量生活质量课程设计报告.doc

1设计时间

2011年12月12日——12月16日

2设计目的

JavaEE课程设计是对所学JavaEE与中间件课程的小结,是提高学生对所学知识综合应用能力的一种方式,是集中实践性环节之一。

要求同学们对课程中所学习到的知识综合运用,开发有一定规模的JavaWeb程序。

3设计任务

设计生活质量衡量系统

(1)衡量标准说明:

消费有两种支出:

吃饭支出和其它支出,如果在一段时间内,吃饭支出占总支出的比例超过50%,生活质量为贫困;如果在20-50%之间,为温饱;如果低于20%,生活质量为小康。

(2)功能描述:

用户以合法身份登录系统后,才能进行所有操作;用户可以添加、查看和删除支出情况(支出类型(有两种:

吃饭支出和其它支出)、额度(人民币)、日期)。

(3)添加支出情况

(4)查看支出情况

(5)删除支出情况

(6)统计在某个时间段内,生活质量属于哪个层次

4设计内容

4.1设计题目

生活质量衡量系统。

4.1.1系统功能要求

用只有拥有合法身份才能登录系统,用以合法身份登录后才能进行添加、查看和删除支出情况(支出类型(有两种:

吃饭支出和其它支出)、额度(人民币)、日期)。

4.1.2数据库存储要求

数据的存储要求:

吃饭支出其他支出,日期。

4.1.3数据库的设计

图1—1(数据库存储表)

图1—2(数据库存储数据)

4.1.4系统构造关系

登陆窗口

密码

no

yes

操作界面

计算

删除

插入

查询

图1—3(jsp页面构造)

Jsp页面传递参数

调用servlet类

参数

计算方法servlet

删除方法servlet

查询方法servlet

插入方法servlet

删除方法dao类

查询方法dao类

插入方法dao类

计算方法dao类

图1—4(Java类功能调用)

4.2Jsp页面设计

4.2.1登录界面

图1—4(登录界面)

代码如下:

欢迎登陆生活质量衡量系统!

用户名称:


用户密码:


4.2.2登录成功界面

图1—5(登录成功查询界面)

登陆成功!

点击获得详细的信息~~

4.2.3查询结果界面

图1—6(查询结果界面)

4.3Java方法设计

4.3.1Servlet类

(1)密码验证的Servlet类的代码如下:

publicclassLoginServletextendsHttpServlet{

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

doPost(request,response);

}

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

Stringusername=(String)request.getParameter("username");

Stringuserpsw=(String)request.getParameter("userpsw");

System.out.println(username);

Stringforward="";

if(username.equals("123")&&userpsw.equals("123")){

forward="/success.jsp";

}else{

forward="/error.jsp";

}

(2)显示所有信息的servlet类代码设计如下:

publicclassListAllThingServletextendsHttpServlet{

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

doPost(request,response);

}

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

ThingDAOthingDAO=newThingDAO();

Listlist=thingDAO.getAllThing();

request.setAttribute("allthing",list);

request.getRequestDispatcher("/showAllThing.jsp").forward(request,response);

}

}

(3)控制增删改操作的servlet类代码设计如下:

插入支出情况代码:

publicclassSaveOutServletextendsHttpServlet{

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

doPost(request,response);

}

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

doublex=0.0;

doubley=0.0;

x=Double.parseDouble(request.getParameter("eating"));

y=Double.parseDouble(request.getParameter("others"));

Stringtimes=(String)request.getParameter("times");

ThingDAOthingDAO=newThingDAO();

try

{

thingDAO.saveUser(x,y,times);

}

catch(Exceptione)

{

e.printStackTrace();

}

Listlist=thingDAO.getAllThing();

request.setAttribute("allthing",list);

request.getRequestDispatcher("/showAllThing.jsp").forward(request,response);

}

}

删除支出情况代码:

publicclassDeleteOutServletextendsHttpServlet{

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

doPost(request,response);

}

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

doublex=0.0;

x=Double.parseDouble(request.getParameter("eating"));

ThingDAOthingDAO=newThingDAO();

try

{

thingDAO.deleteUser(x);

}

catch(Exceptione)

{

e.printStackTrace();

}

Listlist=thingDAO.getAllThing();

request.setAttribute("allthing",list);

request.getRequestDispatcher("/showAllThing.jsp").forward(request,response);

}

}

衡量生活质量代码:

publicclassCaculateextendsHttpServlet{

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

doPost(request,response);

}

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

Stringtime1=request.getParameter("time1");

Stringtime2=reques

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

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1