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>
简单说就是代理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>
相关文章推荐
- struts2中的constant介绍之struts.objectFactory与spring的整合
- struts2中的constant介绍之struts.objectFactory与spring的整合
- struts2中的constant介绍之struts.objectFactory与spring的整合
- Spring的一些理解;struts整合spring
- struts2整合spring后常会忽略的一些细节导致注入service时失败,程序运行报空指针。
- Struts2 的一些基本配置 <constant name="struts.objectFactory" value="spring" />
- ssh整合出现的一些问题总结(spring4+struts2+hibernate4)
- struts2中的constant介绍之struts.objectFactory与spring的整合
- struts2中的constant介绍之struts.objectFactory与spring的整合
- spring 和struts整合过程遇到的一些错误
- struts2中的constant介绍之struts.objectFactory与spring的整合
- struts2中的constant介绍之struts.objectFactory与spring的整合
- Struts2和Spring整合时使用Struts-plugin的注意点
- struts2,hibernate,spring整合笔记(4)--struts与spring的整合
- struts整合spring插件出现如下异常:Unable to load jar:struts2-spring-plugin-2.3.15.3.jar!/struts-plugin.xml
- struts2中的constant介绍之struts.objectFactory与spring的整合
- struts2 与struts1和Spring整合时Bean的配置区别
- 【引用】struts2中的constant介绍之struts.objectFactory与spring的整合
- struts2中的constant介绍之struts.objectFactory与spring的整合
- Struts2和Spring整合中的一些问题