背景
在使用Apache tomcat8.5部署sprintboot项目时,打开后过一会出现
org.apache.coyote.http11.Http11Processor.service 解析 HTTP 请求 header 错误 注意:HTTP请求解析错误的进一步发生将记录在DEBUG级别
解决办法
在tomcat里在server.xml文件的Connector连接器中,增加这两个属性配置,key值为属性名,value值是要过滤的字符串的值,配置如下:
relaxedPathChars="|{}[]^" relaxedQueryChars="|{}[]^"
最终配置完整的代码如下:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxParameterCount="1000"
relaxedPathChars="|{}[]^" relaxedQueryChars="|{}[]^"
/>
加上后可以过滤掉这些无效字符。