Web.xml file loading sequence tags

 web.xml configured in load priority context-param -> listener -> filter -> servlet

1. context-param, which is used to provide ServletContext key pair, i.e., the application context information. Our listener, filter, etc. will be used in the initialization information in these contexts it is context-param first loaded .

2. Listener load


  
  
  1. <listener>
  2. <listener- class>org.springframework.web.context.ContextLoaderListener</listener-class>
  3. </listener>

Spring provides an implementation class ServletContentListener ContextLoaderListener listener, such as Listener used, starting Tomcat
When vessel, such action is automatically loaded ApplicationContext configuration information, and if not it will set the initial parameters contextConfigLocation
using default parameters WEB -INF application.xml file in the path. If you need to read a plurality of profiles to customize or modify the default path, can web.xml
settings: 

3. filter loading

4. the servlet is loaded


  
  
  1. <! - Front Controller ->
  2. <servlet>
  3. <! - here's the name and the name of the configuration file should front of a container, like, behind the "-servlet.xml" compiler automatically filled ->
  4. <servlet-name>dispatcher</servlet-name>
  5. <servlet- class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  6. <load-on-startup>1</load-on-startup>
  7. </servlet>

web.xml Configuration


  
  
  1. <?xml version= "1.0" encoding= "UTF-8"?>
  2. <web-app xmlns= "http://xmlns.jcp.org/xml/ns/javaee"
  3. xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation= "http://xmlns.jcp.org/xml/ns/javaee
  5. http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  6. version= "3.1"
  7. metadata-complete= "true">
  8. <! - Listener ->
  9. <listener>
  10. <listener- class>org.springframework.web.context.ContextLoaderListener</listener-class>
  11. </listener>
  12. <! - Root container / context container ->
  13. <context-param>
  14. <param-name>contextConfigLocation</param-name>
  15. <param-value>/WEB-INF/applicationContext.xml</param-value>
  16. </context-param>
  17. <! - Front Controller ->
  18. <servlet>
  19. <! - here's the name and the name of the configuration file should front of a container, like, behind "- the servlet . Xml " compiler automatically filled ->
  20. <servlet-name>dispatcher</servlet-name>
  21. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  22. <load-on-startup>1</load-on-startup>
  23. </servlet>
  24. <servlet-mapping>
  25. <servlet-name>dispatcher</servlet-name>
  26. <url-pattern>/</url-pattern>
  27. </servlet-mapping>
  28. </web-app>

 

 

                        <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#csdnc-thumbsup"></use>
                        </svg><span class="name">点赞</span>
                        <span class="count"></span>
                        </a></li>
                        <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-Collection-G"></use>
                        </svg><span class="name">收藏</span></a></li>
                        <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-fenxiang"></use>
                        </svg>分享</a></li>
                        <!--打赏开始-->
                                                <!--打赏结束-->
                                                <li class="tool-item tool-more">
                            <a>
                            <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                            </a>
                            <ul class="more-box">
                                <li class="item"><a class="article-report">文章举报</a></li>
                            </ul>
                        </li>
                                            </ul>
                </div>
                            </div>
            <div class="person-messagebox">
                <div class="left-message"><a href="https://blog.csdn.net/wl_public">
                    <img src="https://profile.csdnimg.cn/A/B/B/3_wl_public" class="avatar_pic" username="wl_public">
                                            <img src="https://g.csdnimg.cn/static/user-reg-year/2x/2.png" class="user-years">
                                    </a></div>
                <div class="middle-message">
                                        <div class="title"><span class="tit"><a href="https://blog.csdn.net/wl_public" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">wl_public</a></span>
                                            </div>
                    <div class="text"><span>发布了12 篇原创文章</span> · <span>获赞 17</span> · <span>访问量 3万+</span></div>
                </div>
                                <div class="right-message">
                                            <a href="https://im.csdn.net/im/main.html?userName=wl_public" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                        </a>
                                                            <a class="btn btn-sm  bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a>
                                    </div>
                            </div>
                    </div>
    
Released five original articles · won praise 0 · Views 161

 web.xml configured in load priority context-param -> listener -> filter -> servlet

Guess you like

Origin blog.csdn.net/qq_44813090/article/details/104095498