欢迎来到天天文库
浏览记录
ID:43325694
大小:129.88 KB
页数:10页
时间:2019-09-29
《Spring学习指导3-SSH框架整合1》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Spring学习指导3SSH框架整合1配置环境:•MyEclipse10.0•SQLServer2008•Tomcat6.0•Struts2.3•Hibernate3.22•Spring3.0一、Struts2与Spring整合主要步骤:•创建web项目•添加Struts2特性•添加Spring特性•修改web.xml配置,增加Spring的监听器•仓ij建struts・properties:il:struts曲spring托管•修改applicationcontext.xml配置【样例分析】:使用Struts?与Spring框
2、架完成用户登录模块。源代码:1)视图端:userLogin.jsp、success・jsp、error.jspuserLogin・jsp用户名:密码:success・jsp<%@pagelanguage=,,jc?va"impo3、rt=njc?va.utiL・*"pageEncoding=nut/-8n%><%@taglibprefix二"s"uri='7struts-tags"%>成功页而欢迎你,登录成功!4、ml>error・jsp出错啦!1)控制端:UserLoginpackagecom・my.action;importcom・opensymphony・xwork2・ActionSupport;publicclassUserLoginextendsActionSupport{privateStringuserName;privateStringpassword;publicUserLogin(){}publicStringgetUserName(){returnuserName;}publicvoidsetUse5、rName(StringuserName){this・userName=userName;}publicStringgetPassword(){returnpassword;}publicvoidsetPassword(Stringpassword){this.password=password;}publicStringexecute(){returnSUCCESS;3)配置文件web・xmlstruts2org.apache・s6、truts2.dispatcher・ng・filter・StrutsPrepareAndExecuteFiltercontextConfigLocationclasspath:applic7、ationContext•xmlorg・springframework・web.context・ContextLoaderListenerstruts・xmlesultname="successn>/success・jsp/err8、or•jspapplicationcontext•xmlstruts・propertiesstrutseObjectFac
用户名:
密码:success・jsp<%@pagelanguage=,,jc?va"impo
3、rt=njc?va.utiL・*"pageEncoding=nut/-8n%><%@taglibprefix二"s"uri='7struts-tags"%>
4、ml>error・jsp出错啦!1)控制端:UserLoginpackagecom・my.action;importcom・opensymphony・xwork2・ActionSupport;publicclassUserLoginextendsActionSupport{privateStringuserName;privateStringpassword;publicUserLogin(){}publicStringgetUserName(){returnuserName;}publicvoidsetUse
5、rName(StringuserName){this・userName=userName;}publicStringgetPassword(){returnpassword;}publicvoidsetPassword(Stringpassword){this.password=password;}publicStringexecute(){returnSUCCESS;3)配置文件web・xmlstruts2org.apache・s
6、truts2.dispatcher・ng・filter・StrutsPrepareAndExecuteFiltercontextConfigLocationclasspath:applic
7、ationContext•xmlorg・springframework・web.context・ContextLoaderListenerstruts・xmlesultname="successn>/success・jsp/err
8、or•jspapplicationcontext•xmlstruts・propertiesstrutseObjectFac
此文档下载收益归作者所有