Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the SpringMVC interview questions?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Most people do not understand the knowledge points of this "SpringMVC interview questions" article, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "SpringMVC interview questions" article.

Spring MVC is a module of the spring framework and a lightweight Web framework based on MVC. Spring is a very important part of current Web development.

What are the advantages of SpringMVC?

SpringMVC is a typical textbook MVC framework, which is very good for beginners. Other advantages can be summarized as follows:

1. SpringMVC can support a variety of attempt technologies, not just JSP.

2. Integrate with Spring framework (such as IoC container, AOP, etc.)

3. Clear role assignments: front controller (dispatcherServlet), request-to-processor mapping (handlerMapping), processor adapter (HandlerAdapter), view parser (ViewResolver)

4. Mapping strategies that support various requested resources

2. What are the main components of SpringMVC?

(1) Front-end controller DispatcherServlet. Receiving the request and the response result is equivalent to the transponder. With DispatcherServlet, the coupling between other components is reduced.

(2) processor mapper HandlerMapping. Look for Handler based on the requested URL.

(3) processor adapter HandlerAdapter. When writing Handler, you should follow the rules required by HandlerAdapter so that the adapter HandlerAdapter can execute Handler correctly.

(4) processor Handler. When writing Handler, follow the requirements of HandlerAdapter so that the adapter can execute Handler correctly.

(5) View parser ViewResolver. Parse the view and resolve it to the real view (view) according to the logical name of the view.

(6) View View. View is an interface whose implementation class supports different view types (jsp,freemarker,pdf, etc.).

What are the differences between SpringMVC and Struts2?

1. The entrance to springmvc is a servlet or front-end controller (DispatchServlet), while the entrance to struts2 is a filter filter (StrutsPrepareAndExecuteFilter).

2. Springmvc is based on method development (one url corresponds to one method). The request parameters can be passed to the formal parameters of the method, which can be designed as single or multiple cases (recommended singleton). Struts2 is based on class development, and the parameters are passed through the properties of the class, which can only be designed as multiple cases.

3. Struts uses the value stack to store the request and response data, and accesses the data through OGNL. Springmvc parses the request request content through the parameter parser, assigns values to the method parameters, encapsulates the data and view into ModelAndView objects, and finally transmits the model data in ModelAndView to the page through the requests domain. The Jsp view parser uses jstl by default.

IV. The process of using SpringMVC

(1) user sends a request to the front-end controller DispatcherServlet

(2) after receiving the request, DispatcherServlet calls the HandlerMapping processor mapper and requests that the Handle be obtained.

(3) the processor mapper finds the specific processor according to the request url, and returns the processor object and the processor interceptor (if any) to DispatcherServlet.

(4) DispatcherServlet calls HandlerAdapter processor adapter

(5) HandlerAdapter calls a specific processor (Handler, also known as back-end controller) after adaptation.

(6) Handler execution is completed and ModelAndView is returned.

(7) HandlerAdapter returns the Handler execution result ModelAndView to DispatcherServlet

(8) DispatcherServlet passes ModelAndView to ViewResolver view parser for parsing

(9) return specific View after ViewResolver parsing

(10) DispatcherServlet renders the view of View (that is, populating the model data into the view)

(11) DispatcherServlet responds to the user.

The above is about the content of this article "what are the SpringMVC interview questions?" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report