struts1与struts2

来源:互联网 发布:淘宝删除中差评步骤 编辑:程序博客网 时间:2024/05/22 10:26

Struts1

web.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 
 <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/app*.xml</param-value>
</context-param>
<filter>
<filter-name>ChineseFilter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter>
<filter-name>OpenSession</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>ChineseFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>OpenSession</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

 
 
 
  <servlet>
    <servlet-name>action</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>
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

struts配置

<?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="empForm" type="com.web.struts.form.EmpForm" />


  </form-beans>


  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      attribute="empForm"
      input="regiist.jsp"
      name="empForm"
      parameter="method"
      path="/emp"
      scope="request"
      type="org.springframework.web.struts.DelegatingActionProxy" />


  </action-mappings>


  <message-resources parameter="com.web.struts.ApplicationResources" />
</struts-config>

Struts2

web.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <context-param>  
        <param-name>contextConfigLocation</param-name>  
        <param-value>classpath:beans.xml</param-value>  
    </context-param>  
        
    <listener>  
        <listener-class>  
            org.springframework.web.context.ContextLoaderListener  
        </listener-class>  
    </listener>  
     <filter>  
        <filter-name>Struts2</filter-name>  
         <!-- <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>-->
        <filter-class>com.kairgus.common.FCKFilter</filter-class>
    </filter>  
    <filter-mapping>  
        <filter-name>Struts2</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>  
    <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>








































struts.xml配置

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">


<struts>


    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" />
     <constant name="struts.i18n.encoding" value="GB18030" />
    <package name="default" namespace="/" extends="struts-default">
        <default-action-ref name="index" />
        <global-results>
            <result name="error">/error.jsp</result>
        </global-results>


        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception" result="error"/>
        </global-exception-mappings>


       
        <action name="emp_*" class="com.action.EmpAction" method="{1}">
            <result name="input">error.jsp</result>
            <result name="success">/insertAdmin/enterprise_info.jsp</result>
        </action>
        
    </package>


    <!-- Add packages here -->


</struts>


0 0
原创粉丝点击