The params parameter of @RequestMapping is very useful.
My needs are this, now there are two list pages, one is the list page of all users, one is a list page of a certain user, but their JSP page is the same, the URL path I also want the same, single user list page I want to distinguish by passing in the user name.
However, SPRINGMVC cannot match a URL with multiple methods.
@RequestMapping params parameter is a good solution to this problem.
The same URL, as long as the params is different, SRINGMVC will distinguish the matching.
Example of a piece of code in my project:
Java code
- @RequestMapping (value = "/list", Method=requestmethod.get)
- Public String GETALL (model model) {
- Set<groupsecure> secures= redisdao.get ();
- Model.addattribute ("secures", secures);
- return "Group/list";
- }
- @RequestMapping (value = "/list", method=requestmethod.get,params="Method=one")
- < span class= "keyword" style= "Color:rgb (127,0,85); Font-weight:bold ">public string getoneuser ( @RequestParam (Value = "name" ) string name,model model) {
- Set<groupsecure> secures=redisdao.getbyname (name);
- Model.addattribute ("secures", secures);
- return "Group/list";
- }
@RequestMapping params parameter @RequestMapping (params = "Method=save")