老师您好,在执行:curl http://localhost:8081/sys/dept/save.json\?name\=技术部\&seq\=1\&remark\=技术部
报错如下:
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:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
经查,是由于在tomcat 7.0.73添加对http请求url的规范限制,不允许使用包含未编码的花括号的url进行请求。
网上查找了解决办法:可以修改tomcat 配置文件 catalina.properties
1. tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}
或
2. org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
重启后问题仍然存在,URLEncode编码又不会,主要是找不到在哪儿
请问一下,您的环境使用的tomcat版本,我直接保持一致,谢谢。