@RequestMapping Mapping Requests
1.SpringMVC uses @requestmapping annotations to specify which URL requests can be processed by the controller.
2. @requestmapping can be annotated at the controller's class definition and method definition.
(1). Class definition: Provides preliminary request mapping information. The root directory relative to the Web App.
(2). Provides further subdivision mapping information. Relative to the URL at the class definition.
If @requestmapping is not marked at the class definition,
The URL that is tagged at the method is relative to the Web app's root directory.
3.DispatcherServlet intercepts the request, it is @requestmapping through the controller
The mapping information provided determines the processing method that the request corresponds to.
@Controller @requestmapping ("/hello") Public class Hellocontroller { @RequestMapping ("/helloworld") public String Helloword () { System.out.println ("Hello world!" ); return "Success"; }}
code example:
springmvc-@RequestMapping Mapping Request