Skip to content

Commit 05d6162

Browse files
committed
StringHttpMessageConverter defaults to UTF-8 for JSON
Issue: SPR-17568
1 parent 8eef97d commit 05d6162

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ private Charset getContentTypeCharset(@Nullable MediaType contentType) {
126126
if (contentType != null && contentType.getCharset() != null) {
127127
return contentType.getCharset();
128128
}
129+
else if (contentType != null && contentType.isCompatibleWith(MediaType.APPLICATION_JSON)) {
130+
// Matching to AbstractJackson2HttpMessageConverter#DEFAULT_CHARSET
131+
return StandardCharsets.UTF_8;
132+
}
129133
else {
130134
Charset charset = getDefaultCharset();
131135
Assert.state(charset != null, "No default charset");

0 commit comments

Comments
 (0)