1. DelegatingRequestProcessor with spring replacement struts of the RequestProcessor.

1) not to set up in web.xml automatically loads the ApplicationContext in the struts-config.xml Zhongtong plug-in settings.

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property value="/WEB-INF/applicationContext.xml,/WEB-INF/appContext.xml" property="contextConfigLocation" />
</ plug-in>

2) in struts-config.xml to set up replacement RequestProcessor Class.

<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"> </ controller>

3) not to at the struts-config.xml <Action> action element of the type property set.

<action path = "/ login" input = "/ index.jsp"
validate = "true" scope = "request">
<forward name="forward" path="/success.jsp"> </ forward>
</ action>

4) In the applicationContext.xml or other spring bean configuration file DelegatingRequestProcessor forward from the bean, this bean is the Action category.

<bean name="/login" singleton="false">
<property name="property1" ref="otherbean"/>
</ bean>



II. Use DelegatingActionProxy, such methods are in action at the request and then forward to the definition in applicationContext.xml at Action.

1) with the first method of 1).

2) If the test of the first method is to remove the struts-config.xml

<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"> </ controller>

Element.

3) required in the struts-config.xml in the definition of action of type = "org.springframework.web.struts.DelegatingActionProxy". That is, the first method of 3) add type property.

<action path = "/ login" input = "/ index.jsp" validate = "true"
scope = "request" type = "org.springframework.web.struts.DelegatingActionProxy">
<forward name="forward" path="/success.jsp"> </ forward>
</ action>

4) with the first method of 4).



Three. The use of Spring's ActionSupport.

Spring's ActionSupport succession to org.apache.struts.action.Action

ActionSupport the subclass could or have the global variable type WebApplicationContext. Through getWebApplicationContext () access to this variable.

This is a servlet code:



public class LoginAction extends org.springframework.web.struts.ActionSupport {
            public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
             LoginForm loginForm = (LoginForm) form;
            //获得  WebApplicationContext  对象
        WebApplicationContext ctx = this.getWebApplicationContext();
            LoginDao dao = (LoginDao) ctx.getBean("loginDao");
            User u = new User();
            u.setName(loginForm.getName());
            u.setPwd(loginForm.getPwd());
            if(dao.checkLogin(u)){
            	return mapping.findForward("success");
            }else{
           	 return  mapping.findForward("error");
            }
            }
            }
            applicationContext.xml 中的配置
            <beans>
            	<bean/>
            </beans>