只需要在application.yaml中配置tomcat.uri-encoding=utf-8和servlet.encoding.charset=utf-8
server:
port: 8088
servlet:
context-path: /
encoding:
enabled: true
force: true
charset: UTF-8
compression:
enabled: true
tomcat:
uri-encoding: UTF-8
spring:
main:
banner-mode: off #关闭控制台banner
messages:
basename: i18n/message #国际化配置文件地址
encoding: utf-8
mvc:
pathmatch:
matching-strategy: ant_path_matcher #不加会导致出错springboot集成Swagger2启动报错
thymeleaf:
#开启thymeleaf视图解析
enabled: true
#模板的模式,支持 HTML, XML TEXT JAVASCRIPT
mode: HTML
#编码 可不用配置
encoding: UTF-8
#开发配置为false,避免修改模板还要重启服务器
cache: false
servlet:
content-type: text/html
#配置模板路径,默认是templates,可以不用配置
prefix: classpath:/templates/
#后缀名
suffix: .html
该配置文件详细设置了SpringBoot应用的字符编码,包括tomcat的uri-encoding和servlet的charset为UTF-8,确保了应用的国际化编码正确。同时,配置了Thymeleaf模板引擎的相关参数,如模板模式、编码和缓存设置,以及禁用了控制台banner和调整了Swagger2的路径匹配策略。
238

被折叠的 条评论
为什么被折叠?



