日期:2014-05-18  浏览次数:20667 次

谁能给我一段Struts中,切换多语言的代码?
我现在需要做一个通过在页面上点击不同国别的国旗切换到相应的语言的代码。我以前有一份,现在丢了。谁能在给我一段???

------解决方案--------------------
很简单

核心在action里 资源文件配置默认的,中文的,英文的
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
LanguageForm languageForm = (LanguageForm) form;
// TODO Auto-generated method stub
Locale lo=null;
if(languageForm.getType().equals( "zw ")){
System.out.println( "中文 ");
lo=Locale.SIMPLIFIED_CHINESE;
}
if(languageForm.getType().equals( "yw ")){
System.out.println( "英文 ");
lo=Locale.US;
}
request.getSession().setAttribute(Globals.LOCALE_KEY,lo);
return mapping.findForward( "success ");
}