struts2和spring结合时,action的class属性应该写什么
2010-12-25 21:19
429 查看
这个问题是看马士兵的视频想到的,其实在Struts 2 Documentation里面已经规定的很清楚了。
Normally, in struts.xml you specify the class for each Action. When using the default SpringObjectFactory, the framework will ask Spring to create the Action and wire up dependencies as specified by the default auto-wire behavior.
也就是说,你class指定的是真正的class 也就是com.my.*这种的话那就是 wire up dependencies as specified by the default auto-wire behavior,就是自动注入action里面的属性,默认是by name。
you might want the bean to be completely managed by Spring.如果要完全的将action交给spring管理,那么all you have to do is configure the bean in your Spring applicationContext.xml and then change the class attribute from your Action in the struts.xml to use the bean name defined in Spring instead of the class name.
只要把class属性的名字写成bean的名字。
这样经过我测试就不会自动注入,原因的话我想是struts在这已经对action完全失去控制,也就不会让spring给你注入了,因为
struts.objectFactory.spring.autoWire的属性是写在struts2-spring-plugin-2.jar这个里面的struts-plugin.xml文件里面的
Normally, in struts.xml you specify the class for each Action. When using the default SpringObjectFactory, the framework will ask Spring to create the Action and wire up dependencies as specified by the default auto-wire behavior.
也就是说,你class指定的是真正的class 也就是com.my.*这种的话那就是 wire up dependencies as specified by the default auto-wire behavior,就是自动注入action里面的属性,默认是by name。
you might want the bean to be completely managed by Spring.如果要完全的将action交给spring管理,那么all you have to do is configure the bean in your Spring applicationContext.xml and then change the class attribute from your Action in the struts.xml to use the bean name defined in Spring instead of the class name.
只要把class属性的名字写成bean的名字。
这样经过我测试就不会自动注入,原因的话我想是struts在这已经对action完全失去控制,也就不会让spring给你注入了,因为
struts.objectFactory.spring.autoWire的属性是写在struts2-spring-plugin-2.jar这个里面的struts-plugin.xml文件里面的
相关文章推荐
- struts2与spring集成时action的class属性设置
- struts2 和 spring整合时的 Action class ... not found 异常
- struts2 spring集成时struts.xml文件中action的class属性值意义
- SSH整合问题:struts2-spring-plugin自动注入action的属性所产生的问题
- struts2 spring集成时action的class属性值意义
- struts2 spring集成时struts.xml文件中action的class属性值意义
- struts2中struts.xml中的action标签的method属性配置为"{1}"的时候是什么意味
- struts2 spring集成时struts.xml文件中action的class属性值意义
- 关于struts2结合spring 创建action的思考 singleton prototype
- struts2与spring集成时,关于class属性及成员bean自动注入的问题
- struts2 spring集成时struts.xml文件中action的class属性值意义
- 【j2ee spring】20、S2SH框架中,把struts2的action交给Spring管理有什么好处?
- struts2与spring集成时action的class属性值意义
- struts2 spring集成时action的class属性值意义
- struts2 spring集成时struts.xml文件中action的class属性值意义
- struts2与spring集成时,关于class属性及成员bean自动注入的问题
- struts2 spring集成时struts.xml文件中action的class属性值意义
- struts2 spring集成时struts.xml文件中action的class属性值意义
- struts2 spring集成时struts.xml文件中action的class属性值意义
- struts2与spring集成时,关于class属性及成员bean自动注入的问题