在在springboot下学习使用velocity模板的时候,程序跑起来页面显示中文都是乱码,下面给出我自己的解决办法:
首先在application.propertise中
spring.velocity.charset=UTF-8
spring.velocity.properties.input.encoding=UTF-8
spring.velocity.properties.output.encoding=UTF-8
spring.velocity.resource-loader-path=classpath:/templates/
spring.velocity.suffix=.vm
其次把vm模板文件的编码改成utf-8,右键properties
最后在浏览器中的编码也改成utf-8,最好保持一致这样应该不会出现乱码
本文介绍了解决SpringBoot环境下Velocity模板中文乱码的方法。主要包括:在application.properties配置文件中设置字符集编码;确保VM模板文件编码为UTF-8;调整浏览器编码设置。
1461

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



