简体   繁体   English

Spring Data JPA-编码UTF-8不起作用

[英]Spring Data JPA - Encoding UTF-8 doesn't work

When I'm doing 当我做的时候

repository.save(entity)

characters like "č","š", ... will be displayed as "?". 诸如“č”,“š”,...之类的字符将显示为“?”。 I'm able to display the data right before that line of code and it is formated normally. 我能够在该行代码之前显示数据,并且其格式正常。 Also insert through terminal works fine. 通过端子插入也可以正常工作。

Tried many things like : 尝试了很多事情,例如:

spring.datasource.url= jdbc:mysql://localhost:3306/database?useUnicode=yes&characterEncoding=UTF-8
connection.useUnicode=true
connection.characterEncoding=utf-8
hibernate.connection.useUnicode=true
hibernate.connection.characterEncoding=UTF-8
spring.datasource.sqlScriptEncoding=UTF-8

spring.thymeleaf.encoding=UTF-8
spring.mvc.formcontent.putfilter.enabled=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true

and non of them work. 他们都不工作。 I'm using Spring Boot 2.0.0M2 and also Spring Security. 我正在使用Spring Boot 2.0.0M2以及Spring Security。

& should not be added to the connection string. 不应添加到连接字符串中。 Spring ensures the url is encoded when the actual connection is made. Spring确保在进行实际连接时对url进行编码。

Also the correct param to be set when the connection is made is useUnicode=true 同样在建立连接时要设置的正确参数是useUnicode=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM