-
在resources创建文件
messages_zh_CN.properties(中文),写入
#Unicode转码 hello=\u4f60\u597D
messages_en_US.properties(英文),写入
hello=hello world
结构如图
-
创建配置类
@Configuration @EnableAutoConfiguration @ComponentScan public class LocaleConfig implements WebMvcConfigurer { //Cookie @Bean public LocaleResolver localeResolver()
SpringBoot 国际化LocaleContextHolder的基本配置
最新推荐文章于 2024-07-26 16:28:16 发布
本文介绍了如何在SpringBoot项目中实现国际化,通过创建不同语言的properties文件,如messages_zh_CN.properties和messages_en_US.properties,并配置相应类,以根据请求参数切换语言环境。测试访问地址包括设置为中文和英文的示例。
摘要由CSDN通过智能技术生成