【发布时间】:2010-12-14 08:30:10
【问题描述】:
我们正在扩展一个旧的 Struts 1 项目以由 Spring 管理 - 但我们希望尽可能少地更改代码和流程。因此,我们决定让 Struts 来管理请求,并通过 org.springframework.web.struts.DelegatingActionProxy 类委派操作。
例子:
struts-config.xml 包含:
<action name="InvalidSession"
path="/pages/InvalidSession"
type="org.springframework.web.struts.DelegatingActionProxy"
scope="request">
<forward name="success" path="/pages/Startup.do" />
</action>
action-servlet.xml 包含:
<bean name="/pages/InvalidSession"
class="com.xxx.actions.InvalidSessionAction" />
现在剧情变厚了:
普通 Spring bean 已在 applicationContext.xml 中定义。一个例子:
<bean id="parserUtils" class="com.xxx.el.parser.ParserUtils" >
<property name="parserFactory" ref="parserFactory"/>
</bean>
我现在希望将parserUtils bean 连接(不是自动 - 但这不是问题)到 ActionForm。
如果我想将其连接到 Action,我只需在 action-servlet.xml 中定义以下内容:
<bean name="/pages/CaseUpdate"
class="com.xxx.actions.CaseUpdateAction" >
<property name="parserUtils" ref="parserUtils" />
</bean>
struts-config.xml 中有以下内容:
<action path="/pages/CaseUpdate"
name="CaseUpdateForm"
type="org.springframework.web.struts.DelegatingActionProxy"
scope="request">
<forward name="success" path="/pages/SwitchView.do" />
</action>
但 stuts-config 还包含以下 ActionForm 定义:
<form-bean name="CaseUpdateForm"
type="com.xxx.forms.CaseUpdateForm" />
我希望将parserUtils bean 连接到 CaseUpdateForm 类。
我必须做什么?
谢谢大家!
【问题讨论】:
-
以下内容对我没有帮助,或者我误解了它:stackoverflow.com/questions/354171/struts-and-spring-together
标签: java spring spring-mvc struts