Springmvc is in Spring on the basis of the architecture. the big thing about Spring is that the bean definition in XML is transformed into a container Beandefinition, and then instantiate it for use by the user.
of our Web of the program Spring Container is : Org.springframework.web.context.support.XmlWebApplicationContext, It is configured in contextloader.properties the. Created when the program initiates initialization of Contextloaderlistener and is saved in ServletContext . Container-loaded XML path is configured in Web. contextconfiglocation Field.
The first one . : Springmvc Where is the configuration file and what is the container?
Springmvc will first see if it already exists Spring container, if present, will be Spring Container as the parent container, generating its own Xmlwebapplicationcontext . If not, it is created directly. Createdat the time ofDispatcherservlet initialization, completed by Init->initservletbean . That is, if you configure multiple dispatcherservlet , they are isolated from each other. :
container to find the XML file path is Servlet of the servlet-name+ "servlet". Xml.
second question: Springmvc How the service is provided.
The approximate code is placed in Doservice , the process code is very clear and can be represented by the following diagram (using take doctrine, which others draw is really good):
Six steps:
1. get Handler ( The Controller we wrote ) and its interceptor according to the configuration.
2. execution of interceptor 's prehandle
3. adapt the Handler and perform
4. execution of interceptor 's posthandle
5. Find the View
6. Enter View to populate the model data and show
The third problem is that our developer platform uses Velocity, How is it integrated?
As you can see from the service flow above, the fifth step is to get View.
by configuration we know that view Org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver , Then the corresponding view velocityview velocity velocityview
then the sixth step is to populate the data, and it will create our Velocity of the Velocitycontext , and then create them based on the template address Template , then give Velocity it.
Of course, this step is a bit of a pit I am still groping.
Spring MVC Explanation