1. Simply talk about the SPRINGMVC workflow?
Process
1, the user sends the request to the front controller Dispatcherservlet
2. Dispatcherservlet received a request to call the Handlermapping processor mapper.
3. The processor mapper finds the specific processor, generates the processor object and the processor interceptor (if any) is returned to Dispatcherservlet.
4. Dispatcherservlet Call Handleradapter Processor Adapter
5, Handleradapter through the adaptation of the call to the specific processor (controller, also known as the back-end controller).
6, controller execution completed return Modelandview
7, Handleradapter the controller execution results Modelandview returned to Dispatcherservlet
8. Dispatcherservlet Pass Modelandview to Viewreslover view parser
9, Viewreslover after parsing return to the specific view
10. Dispatcherservlet the rendered view based on the view (populate the model data into the view).
11, Dispatcherservlet response to users 2. How to solve the POST request Chinese garbled problem, get and how to deal with it?
Add to Web. xml:
<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>
The above can solve the POST request garbled problem. There are two garbled methods for GET request Chinese parameter:
Modify the Tomcat profile add code to match the project code as follows:
<ConnectorURIEncoding="utf-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
Another way to re-encode parameters:
String userName = new
String (Request.getparamter ("UserName"). GetBytes ("Iso8859-1"), "Utf-8")
Iso8859-1 is the tomcat default encoding, and the Tomcat encoded content needs to be encoded by utf-8
What is the main difference between 3.SpringMVC and Struts2? The entrance to the ①SPRINGMVC is a servlet, the front-end controller, and the STRUTS2 entry is a filter filter. ②springmvc is based on method development, the transfer parameters are through the method parameter, can be designed as a single case or multiple examples (recommended single case), Struts2 is based on class development, passing parameters are through the properties of the class, can only be designed as a number of examples.
③struts uses the value stack to store the request and the response data, through the OGNL access data, SPRINGMVC through the parameter parser is to parse the request object content into a method parameter, the response data and the page is encapsulated into a Modelandview object, Finally, the model data is transferred to the page through the request object. The JSP view parser uses Jstl by default.
[Java interview six]SPRINGMVC summary and some questions during the interview.