Tomcat 7 cannot pass the JSON solution

Source: Internet
Author: User
Tags rfc

The previous project has been using TOMCAT6 but for some reason the Tomcat 7 Discovery pass JSON parameter will appear

Using the protocol= "http/1.1" connector (Coyote) after upgrading a site to Tomcat 7.0.73 from 7.0.72 or from anything Earli  Er, a URL with an unencoded {or} (ie.{"search": "IsValid"}), now returns a, error code and logs The following error message: "Info:error parsing http request Header Note:further occurrences of HTTP header parsing err ORS is logged at DEBUG character found in the request target. The valid characters is defined in RFC 7230 and RFC 3986 "

After Baidu, tried a variety of methods, have no effect. Like what


TOMCAT7 the JSON string in the incompatible URL of the version above, the lower version of Tomcat can be replaced (not recommended)

The parameters can be resolved by URL transcoding by the JS method "encodeURIComponent (param)", as follows:

var myurl = ' [{"ItemId": "2", "SkuId": ""}] '; var myotherurl = "Http://localhost:8080/cart/batchremove?data=" + encodeURIComponent (Myurl);

Later saw a blog, suggested that you refer to the original text: 77963622

According to the RFC specification, special characters such as |,{,} are not allowed in the URL, but some URLs may carry these characters in actual production, especially | is still more common. After Tomcat upgraded to 7, the check for URL characters became stricter, and if such characters were present, Tomcat would return a 400 status code directly.

Later, some people put forward the different meanings, see:

After a bargain, the Tomcat developer adds a setting that allows the configuration of special characters that can appear in URLs, but is limited to |,{,} three, see: Systemprops.html#other

This setting is valid in the following versions of Tomcat:

-8.5.x for 8.5.12 onwards

-8.0.x for 8.0.42 onwards

-7.0.x for 7.0.76 onwards

Find the last line of Config/, remove the comment and # add one at the end{}

#tomcat. util.http.parser.httpparser.requesttargetallow=| Instead: tomcat.util.http.parser.httpparser.requesttargetallow=| {}


Tomcat 7 cannot pass the JSON solution

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: 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.