error总结
1. 目录结构(确定是在resources目录结构下)
2. application.properties(指定自定义的目录)
#指定管理国际化资源文件
spring.messages.basename=i20n.login
3.源码(分析)
private Resource
[] getResources(ClassLoader classLoader
, String name
) {
String target
= name
.replace('.', '/');
try {
return (new PathMatchingResourcePatternResolver(classLoader
)).getResources("classpath*:" + target
+ ".properties");
} catch (Exception var5
) {
return MessageSourceAutoConfiguration
.NO_RESOURCES
;
}
}
而不是!!!
4.版本(可能版本之间也有一些兼容问题吧,下面是小编的版本)
<properties>
<thymeleaf.version>3.0.11.RELEASE
</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.2.2
</thymeleaf-layout-dialect.version>
</properties>
<dependencies>
<dependency>
<groupId>org.webjars
</groupId>
<artifactId>jquery
</artifactId>
<version>3.3.1
</version>
</dependency>
<dependency>
<groupId>org.webjars
</groupId>
<artifactId>bootstrap
</artifactId>
<version>4.0.0
</version>
</dependency>
<dependency>
<groupId>org.springframework.boot
</groupId>
<artifactId>spring-boot-starter-thymeleaf
</artifactId>
</dependency>
</dependencies>
最后一点小问题吧...写国际资源文件的时候,变量记得小写...否则在html页面调用的时候可能会出现拿不到参数的情况
转载于:https://blog.csdn.net/weixin_44006311/article/details/105223847