struts 与spring整合关键点
断断续续的学习spring又一个月了,领略到了一些其中的要点。几天成功的把spring2.0+hibernate3.0+struts1.2整合到了一起。尤其是在最后整合spring+struts遇到了问题,从网络中找到了整合方法,但太啰嗦,而且各种没有必要的代码也混在了一起。所以我自己写一个spring2+struts1.2整合的方式。
struts-config.xml中<action>标签中的元素需要重新配置
尤其需要注意:type的变化!
<action attribute="transferForm" input="jsps/Input.jsp"name="transferForm" path="/transfer" scope="request"type="org.springframework.web.struts.DelegatingActionProxy"><forward name="failed" path="/jsps/TransferFailed.jsp" /><forward name="success" path="/jsps/TransferSuccess.jsp" /></action>
<plug-inclassName="org.springframework.web.struts.ContextLoaderPlugIn"><set-property property="contextConfigLocation"value="/WEB-INF/applicationContext.xml" /></plug-in>
<bean name="/transfer" ref="accountService"/></bean>
public class TransferAction extends Action {private AccountService accountService = null;public void setAccountService(AccountService accountService) {this.accountService = accountService;}public ActionForward execute(ActionMapping mapping, ActionForm form,//使用改服务类,进行业务逻辑的操作。return null;}}