我如何"说"Spring Boot使用UTF-8编码,正确显示和保存德语变音?我们使用Sping-Boot 1.1.1(发布)编程Java-Web应用程序,使用TomCat7或Jetty编写Web服务器.数据库是postgresql或h2进行测试.
编辑:
我尝试使用属性文件(感谢答案),但没有看到任何更改.
数据库也是UTF-8 ...当我们向Web服务器发送POST请求时,问题就出现了.Spring-Request-Handler已经获得了破碎的编码值.在下面你可以看到代码的一部分:(它显示了一个Thymeleaf模板的片段)
这是请求处理程序:
@RequestMapping(method = RequestMethod.POST) public String handleUserUpdate(@ModelAttribute(MODEL) UpdateUserCommand command) { //here we cut the broken encoded values }
问候Stef
这有助于:
spring.datasource.url=jdbc:mysql://localhost:3306/securitydb?useUnicode=yes&characterEncoding=UTF-8