[Java interview six] SPRINGMVC Summary and some questions during the interview.

Source: Internet
Author: User

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:

  1. <filter>
  2.     <filter-name>CharacterEncodingFilter</filter-name>
  3.     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  4. <init-param>
  5.         <param-name>encoding</param-name>
  6.         <param-value>utf-8</param-value>
  7.     </init-param>
  8. </filter>
  9. <filter-mapping>
  10.     <filter-name>CharacterEncodingFilter</filter-name>
  11.     <url-pattern>/*</url-pattern>
  12. </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:

    1. <ConnectorURIEncoding="utf-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

Another way to re-encode parameters:

    1. 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.