Spring系列产品大量运用在网站开发中,而Spring Boot是为了简化配置而出现的,理论上讲Spring Boot应该默认配置UTF-8为默认编码
spring-boot文档
spring.http.encoding.charset=UTF-8 # Charset of HTTP requests and responses. Added to the "Content-Type" header if not set explicitly.
spring.http.encoding.enabled=true # Enable http encoding support.
spring.http.encoding.force= # Force the encoding to the configured charset on HTTP requests and responses.
spring.http.encoding.force-request= # Force the encoding to the configured charset on HTTP requests. Defaults to true when "force" has not been specified. 没有指定
spring.http.encoding.force-response= # Force the encoding to the configured charset on HTTP responses.
spring.http.encoding.mapping= # Locale to Encoding mapping
默认就是UTF-8格式了
只需要application.properties中添加
spring.http.encoding.force=true
还可以对以下设置
banner.charset
spring.freemarker.charset
server.tomcat.uri-encoding
spring.mail.default-encoding
spring.messages.encoding
spring.thymeleaf.encoding
网友评论