Merge pull request #30535 from chrisrhut

* gh-30535:
  Add Tomcat locale mapping for Japanese to preserve UTF-8 charset

Closes gh-30535
This commit is contained in:
Moritz Halbritter 2022-04-05 14:16:17 +02:00
commit 18c62e2bf3
2 changed files with 2 additions and 0 deletions

View File

@ -260,6 +260,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
private void resetDefaultLocaleMapping(TomcatEmbeddedContext context) {
context.addLocaleEncodingMappingParameter(Locale.ENGLISH.toString(), DEFAULT_CHARSET.displayName());
context.addLocaleEncodingMappingParameter(Locale.FRENCH.toString(), DEFAULT_CHARSET.displayName());
context.addLocaleEncodingMappingParameter(Locale.JAPANESE.toString(), DEFAULT_CHARSET.displayName());
}
private void addLocaleMappings(TomcatEmbeddedContext context) {

View File

@ -411,6 +411,7 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory
// override defaults, see org.apache.catalina.util.CharsetMapperDefault.properties
assertThat(getCharset(Locale.ENGLISH)).isEqualTo(StandardCharsets.UTF_8);
assertThat(getCharset(Locale.FRENCH)).isEqualTo(StandardCharsets.UTF_8);
assertThat(getCharset(Locale.JAPANESE)).isEqualTo(StandardCharsets.UTF_8);
}
@Test