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

在struts2中使用spring对象工厂

2009-07-18 11:41 288 查看
1.导入包: struts-spring-plugin-xxx.jar

2.在web.xml中加入代码:

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

3.配置struts.xml

<constant name="struts.objectFactory" value="spring"></constant>

4.Action类的成员变量名(实际上是getter/setter方法的名称) 与 spring配置文件的Bean id名称相同时,由spring工厂提供对象。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: