歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Struts2集成Spring

Struts2集成Spring

日期:2017/3/1 10:00:36   编辑:Linux編程

測試版本:Struts2.3.4 、Spring3.2

1、確保你的struts2-spring插件jar包已經添加

2、將如下代碼復制到web.xml中

<SPAN > </SPAN><context-param>
<SPAN > </SPAN><param-name>contextConfigLocation</param-name>
<SPAN > </SPAN> <param-value>/WEB-INF/classes/beans.xml</param-value> <!-- 此處存放spring的配置文件-->
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

3、在struts.xml中指定objectFactory

<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />

Copyright © Linux教程網 All Rights Reserved