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