Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java “编码问题”;有效字符在RFC 7230和RFC 3986中定义;在Tomcat 9中_Java_Http_Encoding_Character Encoding_Tomcat9 - Fatal编程技术网

Java “编码问题”;有效字符在RFC 7230和RFC 3986中定义;在Tomcat 9中

Java “编码问题”;有效字符在RFC 7230和RFC 3986中定义;在Tomcat 9中,java,http,encoding,character-encoding,tomcat9,Java,Http,Encoding,Character Encoding,Tomcat9,我在一个非常老的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 a

我在一个非常老的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中引入的

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