乱码显示:??login.tip_zh_CN??、??login.choice_zh_CN??等需要国际化的内容

SpringBoot工程国际化乱码解决

1.首先检查国际化文件(.properties)是是否是UTF-8编码的
2.MessageSourceAutoConfiguration自动配置好了管理国际化资源文件的组件,默认的国际化配置文件名前缀是messages,配置文件可以直接放在classpath路径下,文件叫做messages.properties

国际化文件存放路径:classpath:messages*.properties

SpringBoot工程国际化乱码解决

SpringBoot工程国际化乱码解决

 检查后再次访问:

SpringBoot工程国际化乱码解决

 

 

如果在resources下自定义了文件夹存放国际化文件,在springboot全局文件中正确配置好路径

1.resources文件夹下,自定义了i18n文件夹保存国际化文件

SpringBoot工程国际化乱码解决

2.需要在application.properties中配置好国际化

#国际化配置
spring.messages.encoding=UTF-8
spring.messages.basename=i18n.login   
#或者
spring.messages.basename=i18n/login 路径一定要对应好

 访问:
SpringBoot工程国际化乱码解决

 

相关文章:

  • 2021-04-26
  • 2021-09-14
  • 2021-09-11
  • 2021-11-23
  • 2021-10-12
  • 2021-10-16
  • 2021-10-16
  • 2021-10-16
猜你喜欢
  • 2020-04-19
  • 2021-04-03
  • 2019-09-16
  • 2018-11-22
  • 2021-11-08
  • 2021-03-29
  • 2021-11-12
相关资源
相似解决方案