我有一个以下格式的请求网址
http://hostname:port/path¶m1={"vars":[{"a":"val1","b":"^"},{"c":"val2","d":"^"}]}¶m2=Value3|95|3%20-%206%20Months
我按照这个stackoverflow question改变了catalina.properties。
但是根据tomcat documentation,tomcat.util.http.parser.HttpParser.requestTargetAllow属性已被弃用,而relaxPathChars和relaxedQueryChars属性将与Connector标签一起使用。
但是,当我将xml文件更改为下面
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" relaxedQueryChars="^" relaxedPathChars="^"/>
我仍然得到400个字符的错误请求^
我不确定这是否是正确的配置。
理想情况下,在将请求发送到服务器之前,应始终对查询参数进行URL编码。阅读:https://www.talisman.org/~erlkonig/misc/lunatech%5Ewhat-every-webdev-must-know-about-url-encoding/
如果你想沿着relaxQueryChars路线走下去,请注意你的查询中的以下字符也在你应该添加到异常中的集合中:" { } [ ] ^ |
在server.xml中尝试这个:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" relaxedQueryChars='^{}[]|"' />
更深入地了解bug ticket 62273上的relaxedQueryChars / relaxedPathChars。更改已添加到Tomat的所有分支:
我认为你根本不需要relaxedPathChars属性(这是指URL路径上的字符)。但是,the Tomcat team's test results似乎建议以下内容可用于最大向后兼容性:
relaxedPathChars='[]|'
relaxedQueryChars='[]|{}^\`"<>' />
nb /你的查询的第一个arg应划分?不是&
http://hostname:port/path?param1=...¶m2=...¶m3=...