Tomcat 400错误:Invalid character found in the request target. 问题解决方法

来源:互联网 发布:linux系统巡检报告 编辑:程序博客网 时间:2024/06/08 15:11

Tomcat 7.069以后的版本会有这个问题。

最近部署项目的时候,由于MIS配置的是Tomcat 7.0.78的服务端,导致Web应用不正常,报HTTP 400错误(Chrome无异常、IE报错)。问题原因初步判断为7.078版本的服务端接收请求不会对符号进行转义,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)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

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 ‘%2F’ and ‘%5C’ will be permitted as path.delimiters.If not specified, the default value of false will be used.

阅读全文
0 0
原创粉丝点击