diff --git a/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java index 0d71ab756f8..3e59116b039 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java @@ -32,27 +32,30 @@ import org.springframework.util.FileCopyUtils; /** * Implementation of {@link HttpMessageConverter} that can read and write strings. * - *

By default, this converter supports all media types (*/*), and writes with a {@code - * Content-Type} of {@code text/plain}. This can be overridden by setting the {@link - * #setSupportedMediaTypes(java.util.List) supportedMediaTypes} property. + *

By default, this converter supports all media types (*/*), + * and writes with a {@code Content-Type} of {@code text/plain}. This can be overridden + * by setting the {@link #setSupportedMediaTypes supportedMediaTypes} property. * * @author Arjen Poutsma * @since 3.0 */ public class StringHttpMessageConverter extends AbstractHttpMessageConverter { + public static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1"); + private final Charset defaultCharset; private final List availableCharsets; private boolean writeAcceptCharset = true; + /** * A default constructor that uses {@code "ISO-8859-1"} as the default charset. * @see #StringHttpMessageConverter(Charset) */ public StringHttpMessageConverter() { - this(Charset.forName("ISO-8859-1")); + this(DEFAULT_CHARSET); } /** @@ -73,6 +76,7 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter clazz) { return String.class.equals(clazz); @@ -92,13 +96,13 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverterBy default, returns {@link Charset#availableCharsets()}. Can be overridden in subclasses. - * * @return the list of accepted charsets */ protected List getAcceptedCharsets() {