Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC
轉載:(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 3986at 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.
總結
以上是生活随笔為你收集整理的Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 二手车过户车主变更了手机号没改怎么办
- 下一篇: 机油哪个好品牌大一点的?