Q:

UTF-8 encoding with Spring Boot 1.1.1

How can I "say" Spring Boot to use the UTF-8 encoding, to show and save German umlauts correctly?
We are programming a Java-Webapplication using Sping-Boot 1.1.1 (Release) and as webserver a TomCat7 or Jetty. The database is postgresql or h2 for testing.
Edit:
I tried it with the properties file (thanks for the answer), but no changes are visible.
The database is also UTF-8...
Especially the problem comes, when we send a POST-Request to the Webserver.
The Spring-Request-Handler gets already the broken encoded values.
In the following you can see a part of the code:
(It shows a snippet of the Thymeleaf-Template)
<form accept-charset="utf-8" method="post">
        <div class="row">
            <fieldset th:object="${model}">
                <!-- CSRF token -->
                <th:block th:replace="makros :: csrf" />
                <div class="col-sm-4 form-group" >
                    <label for="firstname" th:text="#{edit_user.first_name}">Given Name</label>
                    <input class="form-control required" type="text" required="required" id="firstname" name="firstname" th:field="*{firstName}" />
                </div>
                <div class="col-sm-4 form-group">
                    <label for="firstname" th:text="#{edit_user.last_name}">Family Name</label>
                    <input class="form-control required" type="text" required="required" id="lastname" name="lastname" th:field="*{lastName}" />
                </div>
            </fieldset>
        </div>
 </form>

And this is the request handler for that:
@RequestMapping(method = RequestMethod.POST)
public String handleUserUpdate(@ModelAttribute(MODEL) UpdateUserCommand command) {
   //here we cut the broken encoded values
}

Greetings
Stef

A:

This helped:
spring.datasource.url=jdbc:mysql://localhost:3306/securitydb?useUnicode=yes&characterEncoding=UTF-8

A:

What is wrongly encoded? The request or the response? server.tomcat.uri-encoding is switching the URI decoding to UTF-8 (this is already the case for Jetty).
But that does not do anything for the request body. By default, Spring MVC decodes that with ISO-8859-1 (that is the default per the servlet spec). You need to specify a body encoding in your request if you want it to be decoded using UTF-8. Most users are actually using the CharacterEncodingFilter to achieve the same thing (and ensure consistency).
If that fixes your issue, watch out for #1182 that is meant to provide an auto-configuration for that.

