Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC

    xiaoxiao2023-09-28  145

    转载:(http://blog.csdn.net/zeroso/article/details/70592179)

    错误现象:

    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:1000) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)

    最近部署项目的时候,由于MIS配置的是Tomcat 8.5的服务端,导致Web应用不正常,报HTTP 400错误(Chrome无异常、IE报错)。问题原因初步判断为8.5版本的服务端接收请求不会对符号进行转义,Chrome不异常的原因或许是浏览器自身转义了。具体错误信息如下:


    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.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:472) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:683) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) 12345678910111213

    java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

    查阅了大量资料后,有两种解决方案:

    Plan 1: 更换低版本的Tomcat来规避这种问题。

    Plan 2: 在conf/catalina.properties中最后添加一行:

    org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

    重启服务器后,解决问题。

    官方指南地址:http://tomcat.apache.org/tomcat-8.5-doc/config/systemprops.html

    官方说明:

    org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH

    If this is true ‘/’ and ‘\’ will be permitted as path.delimiters.If not specified, the default value of false will be used.

    相关资源:apache-tomcat-8.zip
    最新回复(0)