这里只是写到配置方法:
第一步:LoginAction:
package com.inspur.actions;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.inspur.forms.*;
public class LoginAction extends DispatchAction {
//响应登录
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("******通过新的方式响应请求***********");
/*
EmployeeForm employeeForm=(EmployeeForm)form;
//构建一个Employee对象
Employee e=new Employee();
e.setId(employeeForm.getId());
e.setName(employeeForm.getName());
e.setLeader(employeeForm.getLeader());
e.setMid("111111");
eif.addEmployee(e);
request.getSession().setAttribute("adder", e);
*/
return mapping.findForward("ok");
}
}
第二步:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//
DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="userForm" type="com.inspur.forms.UserForm" />
</form-beans>
<action-mappings>
<action path="/login" parameter="flag" name="userForm" type="com.inspur.actions.LoginAction">
<forward name="ok" path="/WEB-INF/welcome.jsp"/>
<forward name="err" path="/WEB-INF/login.jsp"/>
</action>
</action-mappings>
<!-- 配置代理请求处理 DelegatingRequestProcessor ,它的用户是
<controller>
<set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>
</controller>
-->
</struts-config>