Java蜘蛛人 欢迎大家

欢迎大家 来到我的blog , 如果我身边的朋友 有什么不懂可以直接来问我 我会细心的帮助你的. 如果网络上的朋友有什么不懂的 可以加我Java蜘蛛人 QQ48187537
posts - 54, comments - 192, trackbacks - 0, articles - 1

Spring 中的国际化

Posted on 2008-03-05 18:09 Java蜘蛛人 --郑成桥 阅读(1323) 评论(1)  编辑  收藏
<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns
="http://www.springframework.org/schema/beans"
    xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation
="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">



<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"></property>

 
</bean>

</beans>
import java.util.Date;
import java.util.Locale;

import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestBean {
    
    
public static void main(String[] args) {
        
        ApplicationContext context
=null;
        
        context
=new ClassPathXmlApplicationContext("guojihua.xml");
        Object[] a
=new Object[]{"郑成桥",new Date()};
    System.out.println(context.getMessage(
"user", a,Locale.SIMPLIFIED_CHINESE));
        
    }

}


上面Object[] 里面的user 是国际化里的配置的
user=\u6B22\u8FCE{0},\u7684\u5230\u6765\u73B0\u5728\u662F{1}

如果看不懂 ,  就直接加我的 QQ 问吧...

Feedback

# re: Spring 中的国际化  回复  更多评论   

2014-04-27 19:26 by 最代码
请参考代码: 基于浏览器首选语言的springmvc和freemarker国际化配置的实现,下载地址:http://www.zuidaima.com/share/1634244049275904.htm

只有注册用户登录后才能发表评论。


网站导航: