Java 如何修复Spring Boot应用程序的UTF-8编码?
下面是我的Spring Boot应用程序的几个配置。我使用FreeMarker作为MVC解析器。 这是maven配置:Java 如何修复Spring Boot应用程序的UTF-8编码?,java,spring,spring-boot,spring-mvc,freemarker,Java,Spring,Spring Boot,Spring Mvc,Freemarker,下面是我的Spring Boot应用程序的几个配置。我使用FreeMarker作为MVC解析器。 这是maven配置: <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-p
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
<jvmArguments>-Dfile.encoding=UTF8</jvmArguments>
</configuration>
</plugin>
</plugins>
</build>
这是我的应用程序.properties
文件的一部分
# FRONTEND
spring.freemarker.enabled=true
spring.freemarker.template-loader-path=classpath:/templates/
spring.freemarker.expose-request-attributes=true
spring.freemarker.content-type=text/html
spring.freemarker.charset=UTF-8
我还将这些行添加到我的.ftl
文件中:
<#ftl encoding='UTF-8'>
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/>
...
</head>
...
但我仍然使用“Windows-1252”编码,这就是为什么我在页面上看不到俄语字母的原因。如何修复它?这有帮助吗?不,不幸的是,它没有帮助尝试用双引号关闭属性值,像这样有帮助吗?不,不幸的是,它没有帮助尝试用双引号关闭属性值,比如
<#ftl encoding='UTF-8'>
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/>
...
</head>