Description: The content of this article is reproduced to: https://my.oschina.net/happyBKs/blog/411547
If there is infringement of the place, please contact me, I will be immediately deleted.
Earlier, we used the @requestmapping identity control to map the request URL to the physical view. However, this mapping of requests is not limited to the return value of the indicated method on the request URL, but it can also make a convention on the properties of the request, such as the method requested, whether it is get or post. If a conditional qualification is made for a method, a physical view cannot be generated and forwarded to the target page when the requested URL is mapped even if the method does not conform.
Here, we define a controller, as follows:
Package com.happyBKs.springmvc.handlers;
Import Org.springframework.stereotype.Controller;
Import org.springframework.web.bind.annotation.RequestMapping;
Import Org.springframework.web.bind.annotation.RequestMethod;
@RequestMapping ("/c3")
@Controller public
class Rmhandler {
@RequestMapping (value= "/success", method= requestmethod.post) public
String handle ()
{
return "SUCCESSRM";
}
}
Note here that the value of the @requestmapping of the method is the original qualification of the return value. Method is the qualification of the request method property.
We create two requests on the request page, a hyperlink and a form form, they request the same URL, but one is the get method and one is the post method. We clicked and found that the GET request could not be forwarded to the target page, post can.
<%@ page language= "java" contenttype= "text/html; Charset=iso-8859-1 "
pageencoding=" iso-8859-1 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
Springmvc.xml, Web. XML refers to the last article.
Click the hyperlink and the result shows:
Back, click on the form request: