首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

struts2调整spring

2012-10-15 
struts2整合springstruts2整合spring? 一个简单的登陆例子1、创建web项目2、导入struts2的jar包?? commons-f

struts2整合spring

struts2整合spring? 一个简单的登陆例子
1、创建web项目

2、导入struts2的jar包

?? commons-fileupload-1.2.1.jar
???commons-logging-1.0.4.jar
???freemarker-2.3.13.jar
???ognl-2.6.11.jar
???struts2-core-2.1.6.jar
???xwork-2.1.2.jar

3、创建类(action类、service接口、service接口的实现类)

struts2调整spring
4、在src下创建struts.xml文件? 用的其实是WEB-INF/classes/struts.xml

<struts>
??? <package name="ss" extends="struts-default">
??? ??? <action name="loginAction" scope="prototype">
??? ??? <property name="loginService" ref="loginService"></property>
??? </bean>

注意:这里的id --oginService要与loginAction中的一致(loginService作为loginAction中的一个属性,并设置set方法)
8、在WEB-INF/web.xml中配置spring信息
??? <context-param>
??? ??? <param-name>contextConfigLocation</param-name>
??? ??? <param-value>
??? ??? ??? /WEB-INF/classes/applicationContext.xml
??? ??? </param-value>
??? </context-param>
??? <listener>
??? ??? <listener-class>
??? ??? ??? org.springframework.web.context.ContextLoaderListener?
??? ??? </listener-class>
??? </listener>

9、创建login.jsp提交表单? 启动到tomcat服务器测试

热点排行