Spring MVC basics of points

What is the principle annotation
comment is essentially a special interface Annotation inherited, the specific implementation class is generated by the Java run-time dynamic proxy class. When we get notes through reflection, returns generated Java run-time dynamic proxy object. Custom annotation method calls through a proxy object, will end up calling the invoke method AnnotationInvocationHandler. This method corresponding to an index value from this memberValues Map. The source memberValues is Java constant pool.
Please describe the Spring MVC workflow? Describe the workflow DispatcherServlet?
(1) The user sends a request to the front-end controller the DispatcherServlet;
(2) the DispatcherServlet after receiving the request, the call processor HandlerMapping mapper request to obtain the Handle;
(. 3) the processor finds particular mapping processor generation processing according to the request url blocker object and a processor (if it is generated) collectively returned to the DispatcherServlet;
(. 4) to call the DispatcherServlet HandlerAdapter processor adapter;
(. 5) adapted through HandlerAdapter specific call processor (Handler, also called back-end) ;
(. 6) perform complete Handler returns ModelAndView;
(. 7) Handler HandlerAdapter is the execution result is returned to ModelAndView the DispatcherServlet;
(. 8) to the DispatcherServlet ModelAndView pass parser parses ViewResolver view;
return after DETAILED view (. 9) ViewResolver parsing;
(10) DispatcherServlet render view of View (model data coming filled view)
(. 11) in response to the DispatcherServlet user.

Spring MVC commonly used annotation what?
@RequestMapping: url mapping for processing a request for comments, and can be used for class or method. For the class, in response to the request by any methods that are based on the class as a parent of the path address.

@RequestBody: annotation data received http request json implemented will convert json java object.

@ResponseBody: Notes achieve conreoller method returns the object into json response to customer objects.

Spring MVC how to set redirection and forwarding?

(1) Forward: the return value preceded by "forward:", such as "forward: user.do name = method4?"

(2) redirect: returning the value preceded by "redirect:", such as "redirect: http: //www.baidu.com"

 

Published 438 original articles · won praise 2 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_37769323/article/details/104623466