ImageVerifierCode 换一换
格式:DOCX , 页数:42 ,大小:162.74KB ,
资源ID:9728464      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9728464.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(MVC综合设计.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

MVC综合设计.docx

1、MVC综合设计昆明理工大学信息工程与自动化学院学生实验报告( 2012 2013 学年 第 一 学期 )课程名称:JAVA EE技术 开课实验室:信自楼444 2012 年 12 月 25 日年级、专业、班计科10级学号201010803116姓名李力成绩实验项目名称实验四 MVC综合设计指导教师杨云飞教师评语 教师签名: 年 月 日一、实验目的通过上机,熟练掌握5层MVC设计模式。二、内容及要求上机内容:用5层MVC分层模式完成用户管理的功能。具有增加、删除、更新、显示、查询等功能。三、步骤及具体实施1、简要描述程序的开发流程、文件部署截图、及各种配置;开发流程:文件部署:数据库:2、程序代

2、码Com.city.oa.action中EmployeeMainAction:package com.city.oa.action;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.city.oa.business.IEmployee;im

3、port com.city.oa.factory.BussinessFactory;public class EmployeeAddAction extends HttpServlet private static final long serialVersionUID = 1L; public EmployeeAddAction() super(); public void destroy() super.destroy(); / Just puts destroy string in log / Put your code here public void doGet(HttpServle

4、tRequest request, HttpServletResponse response) throws ServletException, IOException doPost(request,response); public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException request.setCharacterEncoding(gb2312); String id=request.getParameter(empid)

5、; String name=request.getParameter(name); String password=request.getParameter(password); String ageStr=request.getParameter(age); int age=Integer.parseInt(ageStr); IEmployee emp=BussinessFactory.getEmployee(); try emp.add(id, name, password, age); catch(Exception e) System.out.println(modify Employ

6、ee error:+e.getMessage(); response.sendRedirect(employee/main.do); public void init() throws ServletException / Put your code here Com.city.oa.action中EmployeeDeletAction.java:package com.city.oa.action;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpSer

7、vlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.city.oa.business.*;import com.city.oa.factory.*;public class EmployeeDeletAction extends HttpServlet /* * */ private static final long serialVersionUID = 1L; /* * Constructor of the object. */

8、public EmployeeDeletAction() super(); /* * Destruction of the servlet. */ public void destroy() super.destroy(); / Just puts destroy string in log / Put your code here /* * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * param reques

9、t the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletExceptio

10、n, IOException doPost(request,response); /* * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * param request the request send by the client to the server * param response the response send by the server to the client * throws Servle

11、tException if an error occurred * throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException String userid=request.getParameter(userid); IEmployee emp=BussinessFactory.getEmployee(); try emp.delete(user

12、id); catch(Exception e) System.out.println(DeletEmployee error:+e.getMessage(); response.sendRedirect(main.do); /* * Initialization of the servlet. * * throws ServletException if an error occurs */ public void init() throws ServletException / Put your code here GetIdModify.java:package com.city.oa.a

13、ction;import java.io.IOException;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.city.oa.business.*;import com.city.oa.factory.*;im

14、port com.city.oa.value.*;public class EmployeeGetIdModify extends HttpServlet public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException doPost(request,response); public void doPost(HttpServletRequest request, HttpServletResponse response) throws

15、 ServletException, IOException String id=request.getParameter(empid); IEmployee emp=BussinessFactory.getEmployee(); try EmployeeValue getEmpById=emp.getEmployee(id); request.setAttribute(getEmpById, getEmpById); RequestDispatcher rd=request.getRequestDispatcher(Modify.jsp); rd.forward(request,respon

16、se); catch(Exception e) System.out.println(forward values to modify error:+e.getMessage(); public void init() throws ServletException / Put your code here LoginActionAction.java:package com.city.oa.action;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.Http

17、Servlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import com.city.oa.business.*;import com.city.oa.factory.*;SuppressWarnings(serial)public class EmployeeLoginAction extends HttpServlet public void doGet(HttpServl

18、etRequest request, HttpServletResponse response) throws ServletException, IOException doPost(request,response); public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException String empid=request.getParameter(empid); String password=request.getParam

19、eter(password); boolean check=false; IEmployee emp=BussinessFactory.getEmployee(); try check=emp.check(empid, password); if(check=true) HttpSession session=request.getSession(true); session.setAttribute(empid, empid); catch(Exception e) System.out.println(login error:+e.getMessage(); System.out.prin

20、tln(you have login success); System.out.println(empid +empid); response.sendRedirect(employee/main.do); EmployeeModifyAction.java:package com.city.oa.action;import java.io.IOException;import java.util.*;import com.city.oa.business.*;import com.city.oa.factory.*;import com.city.oa.value.EmployeeValue

21、;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;SuppressWarnings(serial)public class EmployeeMainAction

22、 extends HttpServlet /* * Constructor of the object. */ public EmployeeMainAction() super(); /* * Destruction of the servlet. */ public void destroy() super.destroy(); / Just puts destroy string in log / Put your code here public void doGet(HttpServletRequest request, HttpServletResponse response) t

23、hrows ServletException, IOException /新加的; int countperpage=5; HttpSession session=request.getSession(); String pageIndex=request.getParameter(pageIndex); if(pageIndex=null) pageIndex=1; /原来的; try IEmployee emp=BussinessFactory.getEmployee(); List empList=emp.getlist(); request.setAttribute(empList,e

24、mpList); /新加的; int pageCount; if(empList.size()%countperpage=0) pageCount=empList.size()/countperpage; else pageCount=empList.size()/countperpage+1; session.setAttribute(pageCount, pageCount); session.setAttribute(empListCount, empList.size(); /根据当前页数在查询集合中获取数据 int currentPageIndex=Integer.parseInt(

25、pageIndex); ArrayList pageempList=new ArrayList(); for(int i=0;i=(currentPageIndex-1)*countperpage&i(currentPageIndex)*countperpage) pageempList.add(empList.get(i); System.out.println(i +i); session.setAttribute(pageempList, pageempList); session.setAttribute(currentPageIndex, currentPageIndex); /原来

26、代码; RequestDispatcher rd=request.getRequestDispatcher(main.jsp); rd.forward(request, response); System.out.println(currentPageIndex +currentPageIndex); System.out.println(pageempList +pageempList); System.out.println(pageCount +pageCount); catch(Exception e) String mess=e.getMessage(); response.send

27、Redirect(./error.jsp?mess=+mess); public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException doGet(request,response); public void init() throws ServletException / Put your code here Com.city.oa.bussiness中IEmployee.javapackage com.city.oa.busines

28、s;import java.util.List;import com.city.oa.value.*;public interface IEmployee /增加员工 public void add(String userid,String name,String password, int age)throws Exception; /修改员工 public void modify(String userid,String name,String password, int age)throws Exception; /删除员工 public void delete(String userid)throws Exception; /取得所有员工列表 public List getlist()throws Exception; /取得一个员工 public EmployeeValue getEmployee(String userid)throws Exception; /验证密码 p

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

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