springboot 增加宋体
时间: 2023-06-30 18:24:04 浏览: 59
如果你想在 Spring Boot 项目中使用宋体字体,可以按照以下步骤进行操作:
1. 将宋体字体文件(.ttf 格式)放置在项目的 resource 目录下,比如在 resource/fonts 目录下。
2. 在 Spring Boot 项目的 application.properties 文件中添加以下配置:
```
spring.thymeleaf.mode=HTML
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.cache=false
spring.thymeleaf.content-type=text/html;charset=UTF-8
spring.thymeleaf.template-loader-path=classpath:/templates/
spring.thymeleaf.additional-properties.fonts.simsun=classpath:/fonts/simsun.ttf
```
其中,`spring.thymeleaf.additional-properties.fonts.simsun` 表示宋体字体文件的路径。
3. 在 HTML 页面中使用宋体字体,可以通过以下方式指定:
```
body {
font-family: 'SimSun', sans-serif;
}
```
其中,`SimSun` 表示宋体字体的名称。
这样配置后,Spring Boot 项目中的 HTML 页面就可以正常显示宋体字体了。