tomcat版本为Apache Tomcat/7.0.78
如下url用浏览器访问时返回状态400
http://192.168.34.1/Service.action?method=GetAddress¶m={}
而访问这个正常
tomcat报错信息如下
Mar 06, 2018 9:36:08 AM org.apache.coyote.http11.AbstractHttp11Processor process
INFO: Error parsing HTTP request header
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.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:189)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1028)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
解决方法
参考这篇文章,修改7.0.76以上tomcat配置就可以,可以不降级或者转义
http://blog.csdn.net/aerchi/article/details/77963622
http://tomcat.apache.org/tomcat-8.0-doc/config/systemprops.html#Other
编辑conf/catalina.properties文件,将
tomcat.util.http.parser.HttpParser.requestTargetAllow注释去掉,并添加后面的字符
tomcat.util.http.parser.HttpParser.requestTargetAllow=| { }