Project, create a test class Springmvctest
@Controller @requestmapping ("/springmvc1") Public classSpringmvctest {Private Static FinalString SUCCESS = "SUCCESS"; /*** @RequestMapping In addition to the modification method, you can also modify class * 1, class definition: Provide the requested mapping information. Equivalent to the root of the Web App * 2, Method: Provides further subdivision mapping information. * @return */@RequestMapping ("/testrequestmapping") PublicString testrequestmapping () {System.out.println ("Testrequestmapping"); returnSUCCESS; }}
Notice here that there are @requestmapping annotations on the class, and the method of writing the Testrequestmapping URL mapping request
This time the address path is: http://localhost:xxxx/springmvc1/testRequestMapping can access the Testrequestmapping method.
2. Requestmappging modification request type Get and post
/**@return*/= "/testmethod", method = requestmethod.post) public String TestMethod () { System.out.println ("TestMethod"); return SUCCESS;}
If you use the Get method request, the following error will occur adding the test Post request HTML code
<form action= "Springmvc1/testmethod" method= "POST" > <input type= "Submit" value= "Post submission Method" ></ Form>
This video tutorial Address Wisdom Podcast _springmvc+mybatis a full set of video tutorials
Section II (requestmapping request) Learn about Silicon Valley-SPRINGMVC video tutorial