首页 > 解决方案 > spring-boot 和 thymeleaf 实现中的国际化

问题描述

我正在尝试在 spring-boot 和 thymeleaf 项目中实现国际化,但没有得到预期的结果。 这是当前结果

在下面提供了我的代码和属性文件内容。我的属性文件路径是:src/main/resources

感谢您对此的指导。谢谢你。

HTML 代码:

<body>
    <h1 th:text="#{index.title}">Library</h1>
    <a th:href="@{/books.html}" href="#" th:text="#{index.books.link}">List of books</a>
</body>

messages_zh_CN.properties

main.title=Spring Boot Recipes - 图书馆
index.title=图书馆
index.books.link=图书列表
books.list.title=可用图书
books.list.table.title=标题
books.list.table.author=作者
books.list.table.isbn=ISBN

消息属性

main.title=Spring Boot Recipes - Library
index.title=Library
index.books.link=List of books
books.list.title=Available Books
books.list.table.title=Title
books.list.table.author=Author
books.list.table.isbn=ISBN

标签: spring-bootinternationalizationthymeleaf

解决方案


推荐阅读