spring 与struts 整合
来源:互联网 发布:淘宝抢购软件 编辑:程序博客网 时间:2024/06/05 10:46
1.spring与struts 的整合的主要目的是 让spring ioc 容器来来管理 action ,interceptor,result 的创建和依赖关系
2.spring struts整合 struts 自带了一个插件 struts-spring-plugin 当我们引入此插件的时候 其实spring 和struts2
还没有真正的整合 因为 struts 是web 项目 tomact 还无法加载 spring xml 配置文档 此时打开tomact 时报错的
3.最好去查一下spring 或者struts 的配置文档http://struts.apache.org/docs/spring-plugin.html
4.整合的具体步骤
第一导入struts插件 struts-spring-plugin
第二部 在web.xml 配置2项
<listener> //用来配置web 服务器可以加载 配置文件
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param> //告诉我们的配置文件放在哪个位置
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value><!-- 也可以加载很多的文件用逗号分开 -->
</context-param>
第三部 在struts 配置文件中
步入<constant name="struts.objectFactory" value="spring"></constant> 此配置是struts 的对象由spring创建
<constant name="struts.objectFactory.spring.autoWire" value="name"> 装配类型是按照name 如不配置的话是按照type
最重要的一点是 action 的class 就要去找 spring xml 的bean 了
struts.xml
<action name="hello" class="helloaction" >
<result name="success">/index.jsp</result>
spring.xml
<bean id="helloaction" class="com.ss.action.helloaction" scope="prototype">
<property name="mdao" ref="Mangerdaoimpl"></property>
</bean>
这样就配置完成
2.spring struts整合 struts 自带了一个插件 struts-spring-plugin 当我们引入此插件的时候 其实spring 和struts2
还没有真正的整合 因为 struts 是web 项目 tomact 还无法加载 spring xml 配置文档 此时打开tomact 时报错的
3.最好去查一下spring 或者struts 的配置文档http://struts.apache.org/docs/spring-plugin.html
4.整合的具体步骤
第一导入struts插件 struts-spring-plugin
第二部 在web.xml 配置2项
<listener> //用来配置web 服务器可以加载 配置文件
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param> //告诉我们的配置文件放在哪个位置
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value><!-- 也可以加载很多的文件用逗号分开 -->
</context-param>
第三部 在struts 配置文件中
步入<constant name="struts.objectFactory" value="spring"></constant> 此配置是struts 的对象由spring创建
<constant name="struts.objectFactory.spring.autoWire" value="name"> 装配类型是按照name 如不配置的话是按照type
最重要的一点是 action 的class 就要去找 spring xml 的bean 了
struts.xml
<action name="hello" class="helloaction" >
<result name="success">/index.jsp</result>
spring.xml
<bean id="helloaction" class="com.ss.action.helloaction" scope="prototype">
<property name="mdao" ref="Mangerdaoimpl"></property>
</bean>
这样就配置完成
0 0
- 整合Struts 与Spring
- 整合Struts 与Spring
- 整合Struts 与Spring
- struts与spring整合
- spring与struts整合
- Spring与Struts整合
- Spring与Struts整合
- Spring与struts整合
- Spring与Struts整合
- spring 与struts 整合
- struts与spring整合
- Spring与Struts整合
- spring与struts整合
- Spring与Struts如何整合
- Struts与Spring的整合
- Spring 与 struts 2 整合
- struts与spring的整合
- Spring与Struts如何整合
- java EE中的任务定时器,当到某个时间的时候执行相应的操作
- mysql blob字段导入
- Win8.1无法安装msi软件提示2502、2503错误怎么解决?
- 设计模式之访问者模式
- listview添加头部后判断是否到达顶部的方法
- spring 与struts 整合
- Cpp--STL的组成
- C++获取可使用的COM口列表
- 零基础入门学习Python(6):列表(续)
- HDU 2079 选课时间 【附dp解法】
- Win8.1无法安装msi软件提示2502、2503错误怎么解决?
- Oracle内连接、外连接、右外连接、全外连接小总结
- C#如何调用SQLServer写的函数
- 关于kettle插入报错的数据到目标表