我的请求网址格式如下
http://hostname:port/path¶m1={"vars":[{"a":"val1","b":"^"},{"c":"val2","d":"^"}]}¶m2=Value3|95|3%20-%206%20Months
我根据这个stackoverflow问题更改了catalina.properties 。
但按照Tomcat文档 tomcat.util.http.parser.HttpParser.requestTargetAllow财产已被弃用,relaxedPathChars和relaxedQueryChars属性要与连接器标签代替。
但是,当我将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/
如果您想沿着relaxedQueryChars路线行驶,请注意,来自查询的以下字符也在您应添加到异常的集合中: " { } [ ] ^ |
在您的server.xml中尝试以下操作:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" relaxedQueryChars='^{}[]|"' />
在错误票证62273上可以更深入地了解RelaxedQueryChars / relaxedPathChars。所做的更改已添加到Tomat的所有分支中:
我认为您根本就不需要relaxedPathChars属性(这是指URL路径上的字符)。但是,Tomcat团队的测试结果似乎表明可以使用以下代码来实现最大的向后兼容性:
relaxedPathChars='[]|' relaxedQueryChars='[]|{}^\`"<>' />
nb /您查询的第一个arg应该用?划界。不是&
http://hostname:port/path?param1=...¶m2=...¶m3=...
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句