MVC综合设计Word文档格式.docx

上传人:b****1 文档编号:5247955 上传时间:2023-05-04 格式:DOCX 页数:42 大小:162.74KB
下载 相关 举报
MVC综合设计Word文档格式.docx_第1页
第1页 / 共42页
MVC综合设计Word文档格式.docx_第2页
第2页 / 共42页
MVC综合设计Word文档格式.docx_第3页
第3页 / 共42页
MVC综合设计Word文档格式.docx_第4页
第4页 / 共42页
MVC综合设计Word文档格式.docx_第5页
第5页 / 共42页
MVC综合设计Word文档格式.docx_第6页
第6页 / 共42页
MVC综合设计Word文档格式.docx_第7页
第7页 / 共42页
MVC综合设计Word文档格式.docx_第8页
第8页 / 共42页
MVC综合设计Word文档格式.docx_第9页
第9页 / 共42页
MVC综合设计Word文档格式.docx_第10页
第10页 / 共42页
MVC综合设计Word文档格式.docx_第11页
第11页 / 共42页
MVC综合设计Word文档格式.docx_第12页
第12页 / 共42页
MVC综合设计Word文档格式.docx_第13页
第13页 / 共42页
MVC综合设计Word文档格式.docx_第14页
第14页 / 共42页
MVC综合设计Word文档格式.docx_第15页
第15页 / 共42页
MVC综合设计Word文档格式.docx_第16页
第16页 / 共42页
MVC综合设计Word文档格式.docx_第17页
第17页 / 共42页
MVC综合设计Word文档格式.docx_第18页
第18页 / 共42页
MVC综合设计Word文档格式.docx_第19页
第19页 / 共42页
MVC综合设计Word文档格式.docx_第20页
第20页 / 共42页
亲,该文档总共42页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

MVC综合设计Word文档格式.docx

《MVC综合设计Word文档格式.docx》由会员分享,可在线阅读,更多相关《MVC综合设计Word文档格式.docx(42页珍藏版)》请在冰点文库上搜索。

MVC综合设计Word文档格式.docx

上机内容:

用5层MVC分层模式完成用户管理的功能。

具有增加、删除、更新、显示、查询等功能。

三、步骤及具体实施

1、简要描述程序的开发流程、文件部署截图、及各种配置;

开发流程:

文件部署:

数据库:

2、程序代码

Com.city.oa.action中EmployeeMainAction:

packagecom.city.oa.action;

importjava.io.IOException;

importjavax.servlet.ServletException;

importjavax.servlet.http.HttpServlet;

importjavax.servlet.http.HttpServletRequest;

importjavax.servlet.http.HttpServletResponse;

importcom.city.oa.business.IEmployee;

importcom.city.oa.factory.BussinessFactory;

publicclassEmployeeAddActionextendsHttpServlet{

privatestaticfinallongserialVersionUID=1L;

publicEmployeeAddAction(){

super();

}

publicvoiddestroy(){

super.destroy();

//Justputs"

destroy"

stringinlog

//Putyourcodehere

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

doPost(request,response);

publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)

request.setCharacterEncoding("

gb2312"

);

Stringid=request.getParameter("

empid"

Stringname=request.getParameter("

name"

Stringpassword=request.getParameter("

password"

StringageStr=request.getParameter("

age"

intage=Integer.parseInt(ageStr);

IEmployeeemp=BussinessFactory.getEmployee();

try

{

emp.add(id,name,password,age);

}

catch(Exceptione)

System.out.println("

modifyEmployeeerror:

"

+e.getMessage());

response.sendRedirect("

employee/main.do"

publicvoidinit()throwsServletException{

}

Com.city.oa.action中EmployeeDeletAction.java:

importcom.city.oa.business.*;

importcom.city.oa.factory.*;

publicclassEmployeeDeletActionextendsHttpServlet{

/**

*

*/

/**

*Constructoroftheobject.

publicEmployeeDeletAction(){

*Destructionoftheservlet.<

br>

*ThedoGetmethodoftheservlet.<

*

*Thismethodiscalledwhenaformhasitstagvaluemethodequalstoget.

*@paramrequesttherequestsendbytheclienttotheserver

*@paramresponsetheresponsesendbytheservertotheclient

*@throwsServletExceptionifanerroroccurred

*@throwsIOExceptionifanerroroccurred

*ThedoPostmethodoftheservlet.<

*Thismethodiscalledwhenaformhasitstagvaluemethodequalstopost.

Stringuserid=request.getParameter("

userid"

try

emp.delete(userid);

}catch(Exceptione)

DeletEmployeeerror:

main.do"

*Initializationoftheservlet.<

*@throwsServletExceptionifanerroroccurs

GetIdModify.java:

importjavax.servlet.RequestDispatcher;

importcom.city.oa.value.*;

publicclassEmployeeGetIdModifyextendsHttpServlet{

EmployeeValuegetEmpById=emp.getEmployee(id);

request.setAttribute("

getEmpById"

getEmpById);

RequestDispatcherrd=request.getRequestDispatcher("

Modify.jsp"

rd.forward(request,response);

forwardvaluestomodifyerror:

LoginActionAction.java:

importjavax.servlet.http.HttpSession;

@SuppressWarnings("

serial"

publicclassEmployeeLoginActionextendsHttpServlet{

Stringempid=request.getParameter("

booleancheck=false;

try{

check=emp.check(empid,password);

if(check==true)

{

HttpSessionsession=request.getSession(true);

session.setAttribute("

empid);

}

catch(Exceptione)

{

System.out.println("

loginerror:

}

System.out.println("

youhaveloginsuccess"

empid"

+empid);

EmployeeModifyAction.java:

importjava.util.*;

importcom.city.oa.value.EmployeeValue;

publicclassEmployeeMainActionextendsHttpServlet{

publicEmployeeMainAction(){

//新加的;

intcountperpage=5;

HttpSessionsession=request.getSession();

StringpageIndex=request.getParameter("

pageIndex"

if(pageIndex==null)

pageIndex="

1"

;

//原来的;

try{

IEmployeeemp=BussinessFactory.getEmployee();

List<

EmployeeValue>

empList=emp.getlist();

empList"

empList);

//新加的;

intpageCount;

if(empList.size()%countperpage==0)

pageCount=empList.size()/countperpage;

else

pageCount=empList.size()/countperpage+1;

session.setAttribute("

pageCount"

pageCount);

empListCount"

empList.size());

//根据当前页数在查询集合中获取数据

intcurrentPageIndex=Integer.parseInt(pageIndex);

ArrayList<

pageempList=newArrayList<

();

for(inti=0;

i<

empList.size();

i++)

if(i>

=(currentPageIndex-1)*countperpage&

&

(currentPageIndex)*countperpage)

pageempList.add(empList.get(i));

System.out.println("

i"

+i);

pageempList"

pageempList);

currentPageIndex"

currentPageIndex);

//原来代码;

main.jsp"

rd.forward(request,response);

currentPageIndex"

+currentPageIndex);

pageempList"

+pageempList);

pageCount"

+pageCount);

}catch(Exceptione){

Stringmess=e.getMessage();

response.sendRedirect("

../error.jsp?

mess="

+mess);

doGet(request,response);

Com.city.oa.bussiness中IEmployee.java

packagecom.city.oa.business;

importjava.util.List;

publicinterfaceIEmployee{

//增加员工

publicvoidadd(Stringuserid,Stringname,Stringpassword,intage)throwsException;

//修改员工

publicvoidmodify(Stringuserid,Stringname,Stringpassword,intage)throwsException;

//删除员工

publicvoiddelete(Stringuserid)throwsException;

//取得所有员工列表

publicList<

getlist()throwsException;

//取得一个员工

publicEmployeeValuegetEmployee(Stringuserid)throwsException;

//验证密码

p

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

当前位置:首页 > PPT模板 > 商务科技

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2