美文网首页
Tomcat 带有{,},|等特殊字符,导致url返回400状态

Tomcat 带有{,},|等特殊字符,导致url返回400状态

作者: 答春竹 | 来源:发表于2018-03-06 10:52 被阅读0次

    tomcat版本为Apache Tomcat/7.0.78
    如下url用浏览器访问时返回状态400

    http://192.168.34.1/Service.action?method=GetAddress&param={}

    而访问这个正常

    http://192.168.34.1/Service.action?method=GetAddress

    tomcat报错信息如下

    Mar 06, 2018 9:36:08 AM org.apache.coyote.http11.AbstractHttp11Processor process
    INFO: Error parsing HTTP request header
    Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
    java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
    at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:189)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1028)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

    解决方法

    参考这篇文章,修改7.0.76以上tomcat配置就可以,可以不降级或者转义

    http://blog.csdn.net/aerchi/article/details/77963622
    http://tomcat.apache.org/tomcat-8.0-doc/config/systemprops.html#Other

    编辑conf/catalina.properties文件,将

    tomcat.util.http.parser.HttpParser.requestTargetAllow注释去掉,并添加后面的字符
    tomcat.util.http.parser.HttpParser.requestTargetAllow=| { }

    相关文章

      网友评论

          本文标题:Tomcat 带有{,},|等特殊字符,导致url返回400状态

          本文链接:https://www.haomeiwen.com/subject/mwjlfftx.html