web.xml中DispatcherServlet攔截器的配置詳情


<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

 <servlet>

    <servlet-name>app</servlet-name>
       <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:app-servlet.xml</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>app</servlet-name>

<!-- "/"表示攔截所有的請求(除了jsp),可以訪問首頁index.jsp,並可以接受所有請求到app-servlet.xm中處理-->

<!-- "/*"表示攔截所有請求(包括jsp), 不能訪問任何首頁,因為都被攔截放到app-servet.xml中做處理了-->

<!--  "*.html"表示攔截后綴為html的請求,能訪問首頁index.jsp,不能訪問index.html(被攔截放到app-servlet.xml中了),-->  <! --  而且只能獲取到html后綴的請求-->

<!--  "*.jsp"的配置結果則與"*.html"的配置結果相反,所有*.jsp請求被攔截到app-servlet.xml中做處理,index.jsp不能訪問-->

<!--  只能訪問index.html -->

    <url-pattern>/</url-pattern>
  </servlet-mapping>


---------------------
https://blog.csdn.net/qq_16734411/article/details/80196011 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM