The @requestmapping annotations allow you to define different processor mapping rules.
1. URL Path Mapping
@RequestMapping (value= "item") or @requestmapping ("/item")
Value is an array, you can map multiple URLs to the same method
/*** Check Product List *@return */@RequestMapping (Value= {"ItemList", "Itemlistall" }) PublicModelandview queryitemlist () {//Check Product dataList<Item> list = This. Itemservice.queryitemlist (); //Create Modelandview, set logical view nameModelandview MV=NewModelandview ("ItemList"); //Put the product data in the modelMv.addobject ("ItemList", list); returnMV;}
2. Add to Class
Add @requestmapping (URL) on class to specify a generic request prefix, limiting all method request URLs under this class must start with the request prefix
You can use this method to classify URLs, such as:
The request URL that needs to enter the Queryitemlist () method At this point is:
Http://127.0.0.1:8080/springmvc-web2/item/itemList.action
Or
Http://127.0.0.1:8080/springmvc-web2/item/itemListAll.action
3. Request Method Qualification
In addition to the URL can be set, you can also qualify the request in the method
@RequestMapping (method = Requestmethod.get)
If you access via post, the error is:
HTTP Status 405-request method ' POST ' not supported
For example:
@RequestMapping (value = "ItemList", method = Requestmethod.post)
@RequestMapping (method = Requestmethod.post)
If get access then error:
HTTP Status 405-request method ' GET ' not supported
@RequestMapping (method = {Requestmethod.get,requestmethod.post})
@RequestMapping define different processor mapping rules