spring国际化支持
来源:互联网 发布:飞鹰网络电视直播tv版 编辑:程序博客网 时间:2024/05/14 21:34
Spring对国际化的支持是beanFactory的子接口ApplicationContext所增加的新功能,主要是因为ApplicationContext接口继承了MessageSource接口,MessageSource接口的getMessage(String code,Object[] obj,Locale locale)方法用于对国际化的支持。
在Spring对国际化的支持中我们需要在应用上下文中配置:
<bean id="messageSource" class="org.springframework.context.support.RegourceBundleMessageSource">
<property name="basenames">
<list>
<value>message</value>//表示我们资源文件的basename为message,资源文件的默认路径是在src路径下, 如果我们想把资源文件放在test下,那么<value>test/message</value>
</list>
</property>
</bean>
建立资源文件message_zh_CN.properties hello=你好{0}
message_en_US.properties hello=hello{0}
我们就可以通过ApplicationContext ac=new ClassPathXmlApplicationContext(.....);
String hello=ac.getMessage("hello",new String[]{"hi"},Locale.getDefault(Category.FORMAT));
就可以获取该语言环境下的hello的值
- Spring 国际化支持
- spring 国际化支持
- spring国际化支持
- Spring支持国际化
- Spring国际化支持
- Spring Boot国际化支持
- spring(11)------spring国际化支持
- Spring Applicationcontext的国际化支持
- Spring Applicationcontext的国际化支持
- Spring对国际化的支持
- Spring学习之国际化支持
- Spring ApplicationContext的国际化支持
- Spring 国际化的支持:Spring MVC Velocity
- Spring -- 国际化的支持(MessageResource用法)
- Spring framework(7):国际化支持 i18n
- Spring MVC完成指南(三)国际化的支持
- Spring使用拦截器支持国际化(转)
- Spring 国际化支持 消息传递 以及 AOP 面向方面编程
- 单选框,复选框的多选使用问题
- 数据结构图篇(自己容易理解有误的地方)
- C#解析XML文件
- Free命令每个数字的含义 和 cache 、buffer的区别
- Check the difficulty of problems - POJ 2151 概率dp
- spring国际化支持
- 给控件添加图片
- java web servlet/filter/listener/interceptor区别与联系
- SDL实现生产者消费者
- 最长子序列相关问题
- D3D D3DXMATRIX 结构体
- 《unix高级环境编程》文件和目录——目录操作
- 面试题6 重建二叉树
- Shell自动解压文件