Override StringHttpMessageConverter with UTF-8

Override the default StringHttpMessageConverter provided by the standard
Spring MVC configuration so that is uses UTF-8 instead of the aging
default of the servlet spec (that is ISO-8859-1)

Fixes gh-1800
This commit is contained in:
Stephane Nicoll
2014-11-04 13:12:19 +01:00
parent 8be97fa47d
commit cbd3c39640
3 changed files with 53 additions and 2 deletions

View File

@@ -886,7 +886,8 @@ formatters, view controllers etc.) you can add your own `@Bean` of type
Spring MVC uses the `HttpMessageConverter` interface to convert HTTP requests and
responses. Sensible defaults are included out of the box, for example Objects can be
automatically converted to JSON (using the Jackson library) or XML (using the Jackson
XML extension if available, else using JAXB).
XML extension if available, else using JAXB). Strings are encoded using `UTF-8` by
default.
If you need to add or customize converters you can use Spring Boot's
`HttpMessageConverters` class:
@@ -909,6 +910,9 @@ If you need to add or customize converters you can use Spring Boot's
}
----
Any `HttpMessageConverter` bean that is present in the context will be added to the list of
converters. You can also override default converters that way.
[[boot-features-spring-message-codes]]
==== MessageCodesResolver
Spring MVC has a strategy for generating error codes for rendering error messages