struts2同样和struts1.x一样支持插件的方式来使用各种插件的功能:
今天介绍一下在struts2中使用Spring Plugin.
它的用法如下:
在struts.properties下进行简单配置:
struts.objectFactory = org.apache.struts2.spring.StrutsSpringObjectFactory
或在
struts.xml进行配置:
<struts>
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
...
</struts>
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
...
</struts>
或在web.xml中进行配置:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
<init-param>
<param-name>struts.objectFactory</param-name>
<param-value>org.apache.struts2.spring.StrutsSpringObjectFactory</param-value>
</init-param>
</filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
<init-param>
<param-name>struts.objectFactory</param-name>
<param-value>org.apache.struts2.spring.StrutsSpringObjectFactory</param-value>
</init-param>
</filter>