我不確切知道你選擇如何整合這兩個框架,但從經驗來看,我可以告訴你它的工作原理。
例如我的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