1. Process of loading Spring Web Module
There is a definition in Web.xml
servlet>
servlet-maping>
Therefore, DispatcherServlet is first loaded, showing log
2004-10-04
23:18
: 38,549 info [org.springframework.web.servlet.dispatcherServlet]
-
2004-10-04
23:18
: 38,699 info [org.springframework.web.servlet.dispatcherservlet]
-
What did DispatcherServlets do in the process of loading, I don't see the source code, but according to the log information judgment, it went to find / web-inf/springapp-servlet.xml
2004-10-04
23:18
: 38,839 info [org.springframework.beans.Factory.xml. XmlbeandefinitionReader] -
It then loads Beans according to the definition of springapp-servlet.xml.
I am in springapp-servlet.xml definition:
The DispatcherServlet is then done, for example, to find MultipartResolver / localeresolver / themeresolver / handleradapters / viewResolver. As for what use, I don't know now. 2, page request I first enter a correct JSP file address, the page is displayed correctly, without any log information. I will enter an incorrect JSP file address, and the page gives the app server's prompt information, and there is no log. Then I will enter an incorrect HTM file address, log information: 2004-10-04 23: 43: 15,442 Warn [org.springframework.web.servlet.pagenotfound] - o mapping for [/springapp/i.htm] in dispatcherservlet with name 'SpringApp'> This shows that .jsp files are not processed by Spring's servlet, they will be processed by the App Server. Because the page request filtration is defined in Web.xml: Change index.jsp to <% @ Page session = "false"%> <% @ taglib prefix = "c" uri = "http://java.sun.com/jstl/core"%> <% @ taglib prefix = "FMT" URI = "http://java.sun.com/jstl/fmt"%> <% - Redirected Because We can't set the welcome page to a Virtual URL. -%> The process of SpringAppController is: Public Class SpringAppController Implements Controller { / ** Logger for this class and subclasses * / Protected final log logger = logfactory.getlog (getclass ()); Public ModlandView HandleRequest (httpservletRequest Request, HttpservletResponse Response) Throws servletexception, ioException { String now = (New java.util.date ()). TOSTRING (); Logger.info ("Returning Hello View with" Now); Return New ModelandView ("Web-INF / JSP / HELLO.JSP", "now", now) } } When entering the page request /springapp/index.jsp, redirect to Hello.htm. This page request is handed over to SpringAppController processing. Pay attention to Return New ModelandView ("Web-INF / JSP / HELLO.JSP", "now", now); It returns a ModlandView, which should be handed over to INTERNALRESOURCEVIEWRESOLver because information appears: 2004-10-04 23:53 : 47,942 info [org.springframework.web.servlet.view.internalResourceViewResolver] - We look at ModelandView's constructor: Public modelAndView (View View) {} Public modelAndView (String ViewName) {} Public ModilandView (View View, Map Model) {} Public ModlandView (String ViewName, Map Model) {} Public ModilandView (View View, String Modelname, Object Modelobject) {} Public ModlandView (String ViewName, String Modelname, Object Modelobject) {} The above is: Public ModlandView (String ViewName, String Modelname, Object Modelobject) {} This shows that only one model returns in a modelandview, that is, 1 view plus 0..1 model. Used Model in Hello.jsp: Greetings, IT IS NOW Thus we can see all the processes of a page request: