我不确切知道你选择如何整合这两个框架,但从经验来看,我可以告诉你它的工作原理。
例如我的struts-config.xml中有以下几点:
<struts-config>
<!-- ================== Form Beans ================ -->
<form-beans>
<form-bean name="UploadForm" type="com.foo.bar.forms.UploadForm" />
</form-beans>
<!-- ================== Action Mapping Definitions ================ -->
<action-mappings>
<action path="/pages/UploadFiles" name="UploadForm"
type="org.springframework.web.struts.DelegatingActionProxy" scope="request"
input="/pages/ImportFiles.jsp">
<forward name="success" path="/pages/SwitchView.do" />
</action>
<!-- ================================ Plugins ============================== -->
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/action-servlet.xml, /WEB-INF/applicationContext.xml" />
</plug-in>
</struts-config>
我的行动-servlet.xml文件包含以下bean定义:
<bean name="/pages/UploadFiles" class="com.foo.bar.actions.UploadFilesAction" />
这样的Struts-1保留了MVC的控制权,但Spring“管理”了整个应用程序。
希望它可以帮助
编辑:
你的web.xml应该阿洛斯具备以下条件:
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
编辑2:
嗯,在你的struts-config,你设置了 您的表单的类型为 (com.foo.bar.forms.UploadForm),例如 me。
我的代码工作,但它很奇怪struts 管理窗体bean和弹簧管理 其他豆。
我不认为这很奇怪...
具体,我想知道,如果 有可能做到这一点
是
添加Bean:
<bean name="CaseUpdateForm" class="com.foo.bar.forms.CaseUpdateForm" >
和转换以上的bean:
<bean name="/pages/UploadFiles" class="com.foo.bar.actions.UploadFilesAction">
<property name="updateForm" ref="UpdateForm" />
</bean>
请将这个答案作为编辑移动到你的问题... – Yaneeve 2010-04-15 09:51:12