我们正在为我们的亚洲客户部署一个Java Spring Web应用程序。
关于Spring Web 5.3.3
在Tomcat 9 之上
在openjdk 11 上使用Java 11
在Linux RHEL 7.8(Red hat Enterprise Linux(上
我们的JavaSpringWeb应用程序被配置为使用UTF-8编码。
在setenv.sh
中
...
-Dfile.encoding=UTF-8
-Dsun.jnu.encoding=UTF-8
...
在server.xml
中
...
<Connector server="" port="7780" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"
allowTrace="false"
xpoweredBy="false"
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/css,text/html,text/xml,application/javascript,application/json,application/x-javascript,text/plain,text/javascript"
/>
...
问题:
我们的web服务无法使用图表集x-compound_text
以下是日志中的部分:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.nio.charset.UnsupportedCharsetException: x-compound_text
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
....
Caused by: java.nio.charset.UnsupportedCharsetException: x-compound_text
at java.base/java.nio.charset.Charset.forName(Charset.java:529)
at org.springframework.http.HttpHeaders.getAcceptCharset(HttpHeaders.java:694)
at org.springframework.integration.http.support.DefaultHttpHeaderMapper.getHttpHeader(DefaultHttpHeaderMapper.java:817)
....
我们知道我们需要在应用程序中支持字符集x-compound_text
。
我们知道实验室中的JVM和客户端站点中的JVM不支持字符集x-compound_text
。
支持的字符集为:
Big5, Big5-HKSCS, CESU-8, EUC-JP, EUC-KR, GB18030, GB2312, GBK, IBM-Thai, IBM00858, IBM01140, IBM01141, IBM01142, IBM01143, IBM01144, IBM01145, IBM01146, IBM01147, IBM01148, IBM01149, IBM037, IBM1026, IBM1047, IBM273, IBM277, IBM278, IBM280, IBM284, IBM285, IBM290, IBM297, IBM420, IBM424, IBM437, IBM500, IBM775, IBM850, IBM852, IBM855, IBM857, IBM860, IBM861, IBM862, IBM863, IBM864, IBM865, IBM866, IBM868, IBM869, IBM870, IBM871, IBM918, ISO-2022-CN, ISO-2022-JP, ISO-2022-JP-2, ISO-2022-KR, ISO-8859-1, ISO-8859-13, ISO-8859-15, ISO-8859-16, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, JIS_X0201, JIS_X0212-1990, KOI8-R, KOI8-U, Shift_JIS, TIS-620, US-ASCII, UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, UTF-8, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, windows-31j, x-Big5-HKSCS-2001, x-Big5-Solaris, x-euc-jp-linux, x-EUC-TW, x-eucJP-Open, x-IBM1006, x-IBM1025, x-IBM1046, x-IBM1097, x-IBM1098, x-IBM1112, x-IBM1122, x-IBM1123, x-IBM1124, x-IBM1129, x-IBM1166, x-IBM1364, x-IBM1381, x-IBM1383, x-IBM29626C, x-IBM300, x-IBM33722, x-IBM737, x-IBM833, x-IBM834, x-IBM856, x-IBM874, x-IBM875, x-IBM921, x-IBM922, x-IBM930, x-IBM933, x-IBM935, x-IBM937, x-IBM939, x-IBM942, x-IBM942C, x-IBM943, x-IBM943C, x-IBM948, x-IBM949, x-IBM949C, x-IBM950, x-IBM964, x-IBM970, x-ISCII91, x-ISO-2022-CN-CNS, x-ISO-2022-CN-GB, x-iso-8859-11, x-JIS0208, x-JISAutoDetect, x-Johab, x-MacArabic, x-MacCentralEurope, x-MacCroatian, x-MacCyrillic, x-MacDingbat, x-MacGreek, x-MacHebrew, x-MacIceland, x-MacRoman, x-MacRomania, x-MacSymbol, x-MacThai, x-MacTurkish, x-MacUkraine, x-MS932_0213, x-MS950-HKSCS, x-MS950-HKSCS-XP, x-mswin-936, x-PCK, x-SJIS_0213, x-UTF-16LE-BOM, X-UTF-32BE-BOM, X-UTF-32LE-BOM, x-windows-50220, x-windows-50221, x-windows-874, x-windows-949, x-windows-950, x-windows-iso2022jp
我能够在实验室中使用调试器重现问题
1. Start web application in Exclipse or remote debug.
2. Wait for application to complete loading.
3. Set breakpoint in method java.nio.charset.Charset.lookup, a line before function returns
4. Load a page in application
5. When stopped in breakpoint change value to variable charsetName.
6. Set value to variable charsetName: x-compound_text
7. Continue running
8. Inspect log file
我需要建议,如何在我们的SpringWeb应用程序中添加对字符集x-compound_text
的支持
您确定需要支持x-compound_text吗?检查一下这个问题,在同样的情况下它帮了我很多:Java Spring RestTemplate设置了不需要的头