gpt4 book ai didi

java - Tomcat 9 中的编码问题 "The valid characters are defined in RFC 7230 and RFC 3986"

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:21:31 25 4
gpt4 key购买 nike

我正在使用一个非常 bing 和旧的软件,它与 servlet 一起工作,并且在 URL 中包含重音符号和其他奇怪的字符。 几周前软件从JDK7升级到JDK11,服务器从Tomcat6升级到Tomcat9。

我试过:

- Using URLEncoder in the java part and encodeURI in the javascript part and it works fine, but there are hundreds of places that need this change and it's complicated because it's easy to make a mistake.
- Use the encodeURI in the server.xml of Tomcat but it doesn't change anything. And I've added the relaxedQueryChars tag, but it doesn't accept accents.
- The last thing that I've tried is to add a filter, to try to encode the params of the request, in the web.xml but it doesn't work when the error appears and there's no option to change the order. And another problem is that the ServletRequest has no setParameter so if I can solve the order filter problem I have this one...

我收到这个错误:

Estado HTTP 400 – Bad Request 
java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

代码在 Tomcat6 中运行完美,但随着升级,我们遇到了这个问题。 我正在尝试获取服务器配置解决方案以避免使用代码编码,但我不知道我还能尝试什么...

谢谢!

最佳答案

最后我们决定安装 Tomcat8 而不是 9,因为 Tomcat8.5 中引入了编码更改。

这是一种变通方法,并没有解决真正的编码问题。但是,实际上,尝试在代码的每一部分都使用编码函数是有风险的,因为它可能会产生其他类型的问题。

关于java - Tomcat 9 中的编码问题 "The valid characters are defined in RFC 7230 and RFC 3986",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56794459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com