1. 程式人生 > >struts2專案中web.xml配置

struts2專案中web.xml配置

struts2.5中<filter-class>使用org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter替換org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Struts2Demo2</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
 
<filter>
      <filter-name>struts2</filter-name><!-- filter名稱 -->
      <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> <!-- filter入口 -->
  </filter>
  <filter-mapping>  <!-- filter名稱 -->
        <filter-name>struts2</filter-name>  <!-- 截獲的所有URL -->
        <url-pattern>/*</url-pattern>
  </filter-mapping>
</web-app>