@RequestMapping params parameter @RequestMapping (params = "Method=save")

Source: Internet
Author: User

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
  1. @RequestMapping (value = "/list", Method=requestmethod.get)
  2. Public String GETALL (model model) {
  3. Set<groupsecure> secures= redisdao.get ();
  4. Model.addattribute ("secures", secures);
  5. return "Group/list";
  6. }
  7. @RequestMapping (value = "/list", method=requestmethod.get,params="Method=one")
  8.         < span class= "keyword" style= "Color:rgb (127,0,85); Font-weight:bold ">public  string getoneuser ( @RequestParam (Value = "name" )  string name,model model)  {  
  9. Set<groupsecure> secures=redisdao.getbyname (name);
  10. Model.addattribute ("secures", secures);
  11. return "Group/list";
  12. }

@RequestMapping params parameter @RequestMapping (params = "Method=save")

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.