雇员管理系统-SSH版(三)

一 引入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>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值