Thymeleaf下的国际化配置
1.首先编写i18n文件
在i18n文件下编写login.properties,然后在编写语言加地区的.properties文件。其中login.properties将会在没有或者位区域信息的情况下显示。其目录截图如下所示
2.在html页面中将所需要替换的信息标注
由于采用的是thymeleaf作为模板引擎,更具thymeleaf在html页面中的语法要求替换需要替换的部分。
<label class="sr-only" th:text="#{login.name}">Username</label>
其中placeholder也可以进行替换
<input type="password" class="form-control" placeholder="Password" required="" th:placeholder="#{login.password}">
需要注意的是由于th:text是进行文本替换,对于不是在文本中需要替换的地方可以采用thymeleaf的行内表达式代替。
<input type="checkbox" value="remember-me" > [[#{l