The valid characters are defined in RFC 7230 and RFC 3986


java.lang.IllegalArgumentException: Invalid character found in the request
target. The valid characters are defined in RFC 7230 and RFC 3986
org.apache.coyote.http11.Http11InputBuffer.parseRequestLine
(Http11InputBuffer.java:467)
org.apache.coyote.http11.Http11Processor.service
(Http11Processor.java:294)
org.apache.coyote.AbstractProcessorLight.process
(AbstractProcessorLight.java:66)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process
(AbstractProtocol.java:791)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun
(NioEndpoint.java:1417)
org.apache.tomcat.util.net.SocketProcessorBase.run
(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker
(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run
(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
Note The full stack trace of the root cause is available in the server logs.


Tomcat 7.0.76, 8.0.42, 8.5.12 這些版本之后可以定義requestTargetAllow 屬性來允許
禁止的字符。在tomcat的 catalina.properties文件中添加這一句:
tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}

如果是springboot工程,
可以在SpringBootApplication的的main方法中增加
System.setProperty
("tomcat.util.http.parser.HttpParser.requestTargetAllow","|{}");

補充:
部署到
tomcat運行到時候,tomcat8.5.30是沒有問題的,tomcat8.5.33卻出現了同樣到問題。
去了
官網文檔查看說:tomcat.util.http.parser.HttpParser. requestTargetAllow(This
system property is deprecated. Use the relaxedPathChars and relaxedQueryChars
attributes of the Connector instead)
然后修改server.xml文件,Connector屬性修改為
如下:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"
relaxedQueryChars="[]|{}^&#x5c;&#x60;&quot;&lt;&gt;" redirectPort="8443" />

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM