我有这个配置文件:

@Configuration
@EnableWebSecurity
@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true)
public class MvcConfig implements WebMvcConfigurer {


    @Bean
    public LocaleResolver localeResolver() {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(Locale.ENGLISH);
        return slr;
    }

    @Bean
    public ReloadableResourceBundleMessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:messages");
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }

    @Bean
    public LocaleChangeInterceptor localeChangeInterceptor() {
        LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
        lci.setParamName("lang");
        return lci;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(localeChangeInterceptor());
    }
}

在我定义的application.properties中:spring.messages.encoding=UTF-8

模板:

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      th:lang="${#locale.language}" lang="en">
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
...
</html>

但我在浏览器上看到了这一点:

enter image description here

推荐答案

使用外部编辑器将所有文件保存为UTF-8

Html相关问答推荐

<mat-toolbar更改所有页面的高度

有没有可能设置div的边框宽度相对于其父宽度和高度?'

为什么使用Google字体的SVG徽标内的文本不能在网页上正确呈现?

Angular Project中的星级 Select

如何在伪元素背景中定位多个CSS径向梯度

当光标悬停在(相同)父元素上方时,为多个子元素创建不同的过渡动画

你将如何为手机制作导航栏

try 更新我的Node.js应用程序中的用户,但我收到错误.然而,当我使用postman 时,更新工作正常

减小HTML负载中base64字符串的大小

根据Tailwind CSS中的子计数而非子宽度进行对齐,并水平对齐

30000ms后超时重试:期望找到元素:someElement,但从未找到它

如何将 元素与常规文本垂直对齐

如何为卡片块制作侧丝带样式

在 flexbox 中使用 spacer 是否有效

如何将 2 种不同的 colored颜色 应用于 css 中的复选框?

使用 TailwindCSS 将徽标放在左上角,将菜单放在右上角

如何在 Tailwind CSS 中创建响应式网格布局?

使用 golem 框架在shiny 的应用程序中存储背景图片的位置

CSS 网格自动高度不适用于特定网格区域

以 HTML 格式显示的 LaTeX 表格