Spring MVC Basics @RequestMapping Request mapping using [email protected] Annotations
(1) Specifies that the controller or method can handle those URL requests.
(2) Scope of application: The class definition or the method definition can be added.
(3) Adding the annotation at the class definition is relative to the root of the Web app, and at the method is a further refinement of the request processing defined by the class. You can not add the annotation on the class definition, but the annotation is on the method definition, at which point the URL of the note tag at the method is relative to the web App root.
(4) Thinking: If I do this function, I will scan all the annotations on the controller layer when the application is started, then initialize the annotations to a map collection, and then follow through the URL to the map to query the specific controller. ( personal ideas, concrete implementation without research source, do not know )
[email protected] Detailed mapping of request parameters, request methods, and request headers
The request can be mapped in more detail through @requestmapping, ensuring that only requests that meet the requirements can be entered into the controller. The @RequestMapping contains a mapping condition with value (request URL), method (which can be accessed by request, such as GET, post, and so on), params (the matching field for the request parameter), heads (Request header). These mapping conditions can be used in combination to make the request more granular.
(1) A @requestmapping to control the request mode slightly
@RequestMapping (value= "/helloworld", method = public String Hello () { System.out.println ( "Hello World"); return "Success";}
(2) @requestmapping to control the request parameters and the request header
Working with instances
[Email protected] supports wildcard URL matching
Use case
Spring MVC Fundamentals Article 1