struts2國際化--更改瀏覽器預設語言環境
阿新 • • 發佈:2019-02-03
自己的記錄用的著的就看下ActionContext ctx = ActionContext.getContext(); Locale locale = null; if(language==null){ HttpServletRequest requests=ServletActionContext.getRequest(); String string= requests.getLocale().getLanguage(); if(string=="zh"){ language=ZH_CN; }else { language=EN_US; } } if (ZH_CN.equals(language)) { locale = Locale.SIMPLIFIED_CHINESE; setLanguageCookie(ZH_CN); } if (EN_US.equals(language)) { locale = Locale.US; setLanguageCookie(EN_US); } ctx.setLocale(locale); session2.put("WW_TRANS_I18N_LOCALE", locale);