SPRINGMVC uses @requestmapping annotations to specify which URL requests can be processed by the controller.
can be used for class definitions and method definitions:
Class definition: Provides preliminary request mapping information. The root directory relative to the Web App.
Method: Provides further subdivision mapping information. Relative to the URL at the class definition. If there is no definition at the class definition, it is relative to the root directory.
For example, if the @requestmapping ("Pathclass") annotation is set for the class, @requestmapping ("method") is set for the method, the URL of the final call to the method is Pathclass/method. Full path such as Http://localhost:8080/HelloWorld/pathclass/helloworld.
Refer to the following controller test code:
Packagecom.tiekui.springmvc.handlers;ImportOrg.springframework.stereotype.Controller;Importorg.springframework.web.bind.annotation.RequestMapping, @Controller @requestmapping ("Pathclass") Public classRequestmappingtest {Private StaticString success= "SUCCESS"; @RequestMapping ("HelloWorld") PublicString Hello () {System.out.println ("Hello World from" +getclass ()); returnSUCCESS; }}
The reference code for calling this method in the JSP is as follows, and the following code can be added to the index.jsp in the HelloWorld project.
<href= "Pathclass/helloworld">pathclass Hello World Test</ a>
SPRINGMVC (iii) Requestmapping modified class