在处理某个项目bug时。下载文件–请求参数中包含 [ ]字符,遇到java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
错误。
在tomcat的catalina.properties中加入
tomcat.util.http.parser.HttpParser.requestTargetAllow=|[]{}_
重启,错误,网上百度,requestTargetAllow 只能配置|、{、} 允许这三个字符,对于其他的(例如" < > [ \ ] ^ ` { | } .),在请求时,仍然拦截。
遇到|{}之外的其他字符还需要如下配置。
在conf/server.xml中的节点中,添加2个属性:
relaxedPathChars="|{}[]"relaxedQueryChars="|{}[]"
重启,终于可以下载