Spring MVC(三) 国际化二_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > Spring MVC(三) 国际化二

Spring MVC(三) 国际化二

 2014/5/26 18:27:30  hxl1988_0311  程序员俱乐部  我要评论(0)
  • 摘要:1、java本地化publicclassApp{publicstaticvoidmain(String[]args){Localechina=newLocale("zh","CN");Localehongkong=newLocale("zh","HK");Localetaiwan=newLocale("zh","TW");Localeusa=newLocale("en","US");Localeengland=newLocale("en","GB")
  • 标签:MVC 国际化 Spring

1、java本地化

class="java">public class App 
{
    public static void main( String[] args )
    {
    	Locale china = new Locale("zh", "CN");
    	Locale hongkong = new Locale("zh", "HK");
    	Locale taiwan = new Locale("zh", "TW");

    	Locale usa = new Locale("en", "US");
    	Locale england = new Locale("en", "GB");
    	Locale france = new Locale("fr", "FR");
    	NumberFormat fmt = NumberFormat.getCurrencyInstance(france);
    	double price = 12.88;
    	System.out.println(fmt.format(price));
    }
}

?

public static void messageFormat(Locale locale, Object...params) {
    	String msg = "hello {0}, welcome here to {1}";
    	
    	MessageFormat msgFmt = new MessageFormat(msg, locale);
    	
    	String localeMsg = msgFmt.format(params);
    	
    	System.out.println(localeMsg);
    }

?2、资源命名

资源名_语言代码_国家地区代码.properties

资源名.properties:默认的资源文件

?

3、spring中的MessageSource

org.springframework.context.support.ResourceBundleMessageSource

?

?

发表评论
用户名: 匿名