Parameters contained in requestmapping annotations
Value: Controller name is also a mapping of URLs
The parameters in the Params:url can be multiple
Method:http the requested action. Get post put delete ...
Headers: Request Header Parameters
@PathVariable: Map URL binding placeholder (map the variables inside the URL path)
@Controller//Mapping Controller Classes@RequestMapping ("/hellotest") Public classHello2 { Public Final StaticString DISPATCHER = "Show"; @RequestMapping ("/test") PublicString Testurl () {System.out.println ("Testurl=http://localhost:8080/springmvc/hellotest/test"); returnDISPATCHER; } /*** Test of Get action request *@return */@RequestMapping (Method=requestmethod.get,value= "/testmethodget") PublicString Testmethodget () {System.out.println ("Get ........"); returnDISPATCHER; } /*** Test of Post action request *@return */@RequestMapping (Method=requestmethod.post,value= "/testmethodpost") PublicString Testmethodpost () {System.out.println ("Post ........"); returnDISPATCHER; } /*** Test URL with parameters (not test request header information) *@return */@RequestMapping (Value= "/testheadersandparams", params={"username", "sex!=1", "password=123"}, Method=requestmethod.get) PublicString Testheadersandparams () {//URLhttp://localhost: 8080/springmvc/hellotest/testheadersandparams?username=10&password=123&sex=2System.out.println ("Testheadersandparams"); returnDISPATCHER; } //pathvariable Map URL binding placeholder (map the variables inside the URL path)@RequestMapping (value= "/testpathvariable/{id}", method=requestmethod.get) PublicString testpathvariable (@PathVariable ("id") (Integer ID) {SYSTEM.OUT.PRINTLN ("Testpathvariable ID:" +ID); //http://localhost: 8080/SPRINGMVC/HELLOTEST/TESTPATHVARIABLE/5 returnDISPATCHER; } @RequestMapping (Value= "/testpathvariable2/{name}", method=requestmethod.get) PublicString TestPathVariable2 (@PathVariable ("name") (String name) {System.out.println ("Testpathvariable Name:" +name); // http://localhost: 8080/springmvc/hellotest/testpathvariable2/str returnDISPATCHER; } @RequestMapping () PublicString Test () {returnDISPATCHER; }}
Parameters and usages of the @requestmapping of SPRINGMVC