Java Web Modification Request Parameters

Source: Internet
Author: User

Method One, inherit Httpservletrequestwrapper, implement the custom request

1, in addition to the modified parameters, other headers and other parameters unchanged, equivalent to modify the request parameters

2. The essence is another request

/** * @author Zxguan * @description * @create 2018-03-02 9:51*/ Public classParameterrequestwrapper extends Httpservletrequestwrapper {PrivateMapparams;  PublicParameterrequestwrapper (httpservletrequest request, Map Parammap) {super (request); params=Parammap; } @Override PublicMap<string, string[]>Getparametermap () {return params; }}
// The new hashmap<> is used to regenerate a map, because Request.getparametermap () gets a list of parameters that are not allowed to modify " Java.lang.IllegalStateException:No Modifications is allowed to a locked Parametermap " New Hashmap<>(Request.getparametermap ()); // xxx is the parameter to be overwritten, VALUESTR is the true parameter value, Wraprequest is the newly generated custom request Parammap.put ("xxx"new New Parameterrequestwrapper (Request, Parammap);  

Method Two, did not find! - _ - !

Java Web Modification Request Parameters

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.