当前位置: 首页> 财经> 访谈 > 企业销售型网站是什么_东莞公司注册代理_推广方案策略怎么写_重庆seo排

企业销售型网站是什么_东莞公司注册代理_推广方案策略怎么写_重庆seo排

时间:2025/8/25 20:36:33来源:https://blog.csdn.net/qq_15897815/article/details/143171789 浏览次数:0次
企业销售型网站是什么_东莞公司注册代理_推广方案策略怎么写_重庆seo排

从源码MessageSource的三个实现出发实战spring·i18n国际化 - 简熵 - 博客园

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;import java.util.Locale;
import java.util.ResourceBundle;@SpringBootApplication
public class HelloWorldSpringbootApplication {// ReloadableResourceBundleMessageSource可以加载指定项目以外的国际化文件private static String zhPath ="file:D:/temp/content";public static void main(String[] args) {// SpringApplication.run(HelloWorldSpringbootApplication.class, args);getSpringContent();}@Beanpublic ReloadableResourceBundleMessageSource messageSource() {ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();messageSource.setBasenames(zhPath, "classpath:content");return messageSource;}public static void getSpringContent() {AnnotationConfigApplicationContext ctx =new AnnotationConfigApplicationContext(HelloWorldSpringbootApplication.class);MessageSource source = ctx.getBean(MessageSource.class);Locale localeZh = new Locale("zh","CN");String hello = source.getMessage("hello", null, localeZh);System.out.println("hello = " + hello);}public static void getContent() {Locale localeEn = new Locale("en","US");Locale localeZh = new Locale("zh","CN");ResourceBundle res = ResourceBundle.getBundle("content", localeZh);String hello = res.getString("hello");System.out.println("hello = " + hello);}
}

再加三个文件:

content.properties
hello=123
content_en_US.properties
hello=hello_world

content_zh_CN.properties

hello=456

关键字:企业销售型网站是什么_东莞公司注册代理_推广方案策略怎么写_重庆seo排

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: