一 引入struts开发包
二 创建struts-config.xml,在/WEB-INF目录下
配置如下:
<?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="employeeForm" type="com.hsp.web.forms.EmployeeForm" />
</form-beans>
<action-mappings>
<action path="/login" parameter="flag" name="employeeForm">
<forward name="ok" path="/WEB-INF/MainFrame.jsp"/>
<forward name="err" path="/WEB-INF/login.jsp"/>
</action>
<!-- 配置employeeaction -->
<action path="/employee" name="employeeForm" parameter="flag">
<forward name="goAddEmpUi" path="/WEB-INF/addEmpUi.jsp" />
<forward name="goListEmp" path="/WEB-INF/listEmp.jsp"/>
<forward name="goUpdEmpUi" path="/WEB-INF/updEmpUi.jsp"/>
</action>
</action-mappings>
<!-- 配置全局跳转 -->
<global-forwards>
<forward name="opererr" path="/WEB-INF/err.jsp" />
<forward name="operok" path="/WEB-INF/ok.jsp" />
</global-forwards>
<!-- 配置代理请求处理 DelegatingRequestProcessor ,它的用户是 -->
<controller>
<set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>
</controller>
</struts-config>
三 在web.xml中配置我们的struts
<servlet>
<servlet-name>struts</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>struts</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
四 在web.xml中初始化我们的spring容器
<!-- 指定spring的配置文件,默认从web根目录寻找配置文件,我们可以通过spring提供的classpath:前缀指定从类路径下寻找 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
<!-- 对Spring容器进行实例化 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>