SSM整合之web.xml

最近在使用SSM整合一個通用的後臺管理系統,記錄一下自己的整合過程,方便以後查閱,今天我們來說一下web.xml,該配置文件通常放置在WebRoot/WEB-INF文件夾下面,該配置文件會隨着自己的整合不斷修改。配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>cesoftBaseSystem</display-name>
 <!--開始定義默認啓動頁-->
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <!--結束定義默認啓動頁-->
  <!--開始配置異常處理 --> 
    <error-page>  
      <error-code>404</error-code>  
      <location>/404.html</location>  
   </error-page>  
   <error-page>  
      <error-code>505</error-code>                               
      <location>/505.html</location>  
   </error-page>  
   <error-page>  
      <exception-type>javax.servle.ServletException</exception-type>  
      <location>/error.html</location>  
   </error-page>
   <error-page>  
      <exception-type>java.lang.NullPointerException</exception-type>  
      <location>/error.html</location>  
   </error-page> 
   <!--結束配置異常處理 --> 

   <!-- 開始配置spring核心監聽器,默認會以 /WEB-INF/spring.xml作爲配置文件 -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
     <!-- contextConfigLocation參數用來指定Spring的配置文件-->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring.xml</param-value>
    </context-param>
    <!-- 結束配置spring核心監聽器-->
    <!--開始定義Spring MVC的前端控制器,默認路徑是/WEB-INF/{servlet-name}-servlet.xml,可以修改名稱及路徑-->
   <servlet>  
        <servlet-name>springmvc</servlet-name>  
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
        <init-param>  
            <param-name>contextConfigLocation</param-name>  
            <param-value>/WEB-INF/springmvc-servlet.xml</param-value>  
        </init-param>  
        <load-on-startup>1</load-on-startup>  
        <async-supported>true</async-supported>  
    </servlet>  
    <servlet-mapping>  
        <servlet-name>springmvc</servlet-name>  
        <!-- 此處可以可以配置成*.do,對應struts的後綴習慣 -->  
        <url-pattern>/</url-pattern>  
    </servlet-mapping>  
    <!--結束定義Spring MVC的前端控制器 -->
    <!-- 解決工程編碼過濾器開始 -->  
    <filter>  
        <filter-name>characterEncodingFilter</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-mapping>  
        <filter-name>characterEncodingFilter</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping> 
   <!-- 解決工程編碼過濾器結束日 -->  
</web-app>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章