04-springmvc_requestmapping_ Request Parameters & Request Headers

Source: Internet
Author: User

1 params and headers support for simple expressions
    • PARAM1: Indicates that the request must contain a request parameter named param1
    • !PARAM1: Indicates that the request cannot contain a request parameter named param1
    • Param1!=value1: Indicates that the request contains a parameter named param1, but its value cannot be value1
    • {"Param1=value1", param2}: The request must contain two request parameters named Param1 and param2, and the value of the param1 parameter must be value1
2 Testing the params2.1 controller class
  
 
  1. @RequestMapping(value="/testParams",params={"username","age!=10"})
  2. public String testParams(){
  3. System.out.println("testParams");
  4. return "success";
  5. }
2.2 HTML
 
   
  
  1. <a href="springmvc/testParams?username=imentor&age=10">测试参数</a>
Does not return to the success interface because the age=103 test headers
  
 
  1. @RequestMapping(value="/testHeaders",headers={"zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3"})
  2. public String testHeaders(){
  3. System.out.println("testParams");
  4. return "success";
  5. }
Headers value, which can be obtained by firebug

Donate US
The Mentor Studio has been working to help programmers learn to program more quickly and easily, and if you agree with our results and feel helpful, you are welcome to donate ^_^ to us.     

04-springmvc_requestmapping_ Request Parameters & Request Headers

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.