springMVC國際化及本地化初識

2021-08-03 19:42:36 字數 938 閱讀 9688

locale locale = new locale("zh","cn");

numberformat currfmt = numberformat.getcurrencyinstance(locale);

double amt = 123456.78;

system.out.println(currfmt.format(amt));//¥123,456.78

date date = new date();

dateformat df = dateformat.getdateinstance(dateformat.medium, locale);

system.out.println(df.format(date));//2017-6-25

string pattern1 = ",你好!你於 在工商銀行存入 元。";

string pattern2 = "at on , paid .";

//②用於動態替換佔位符的引數

object params = ;

//③使用預設本地化物件格式化資訊

string msg1 = messageformat.format(pattern1, params);

//④使用指定的本地化物件格式化資訊

messageformat mf = new messageformat(pattern2, locale.us);

string msg2 = mf.format(params);

system.out.println(msg1); //john,你好!你於 17-6-25 下午8:29 在工商銀行存入 1,000 元。

system.out.println(msg2); //at 8:29 pm on june 25, 2017,john paid $1,000.00.

Springmvc框架本地化和國際化

springmvc的本地化和國際化 一 acceptheaderlocaleresolver 這個locale resolvers依據 accept language請求頭資訊進行解析處理,通常這個頭資訊包含客戶端操作資訊的本地標示。二 cookielocaleresolver 這個解析器通過coo...

Spring MVC國際化配置

一 基於瀏覽器語言的國際化配置 使用spring的mvc,並且配置中有配置resource檔案 其中,message info是你的properties檔案的通用名。如 我的配置檔案叫message info.properties,message info zh cn.properties等等,只要...

SpringMVC的國際化

關於springmvc的國際化,這篇文章已經講的很好了。它講了有如下幾種國際化方式 1 基於http的header資訊的國際化 request.getlocale 2 基於session的國際化 設定session的sessionlocaleresolver.locale session attri...