您的位置:首页 > 编程语言 > Java开发

struts2的一些用法(五):struts2+Spring整合

2008-12-15 12:34 405 查看
关于整合其实简单的要命的事情,暂时只掌握到struts整合的一种方式;
简单说就是代理Action:
步骤:
1.导入包--struts2-spring-plugin-2.0.11
2.以及web.xml设置spring的listener:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

3.建立applicationContext.xml,不过存放位置不同哦,是WEB-INF包下,不是以前的位置了;
<bean id="user_action" class="com.wang.action.User_Action" scope="prototype">
//id代理的action名字
......

4.struts.xml设置:
<action name="login" class="user_action">
//class是代理action

另外,applicationContext.xml的位置是可以在web.xml配置的;
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
//配置位置,此处配置是指src下

</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: