1,在servlet里面用request.getlocal()去获得本地的国家。
返回值是locale类型的,local.getcountry可以获得国家编号。
2.把页面的词语都改成el表达式,然后改变语种即可.
返回值是locale类型的,local.getcountry可以获得国家编号。
2.把页面的词语都改成el表达式,然后改变语种即可.
Locale locale=null;
String language=request.getParameter("local");
System.out.println(language+"language");
if(language==null||"".equals(language)){
locale= request.getLocale();
}else if(language.equals("zh")){
locale=new Locale("zh","CN");
}else if(language.equals("en")){
locale=new Locale("en","US");
}
String county=locale.getCountry();
ResourceBundle rBundle=ResourceBundle.getBundle("res",locale);
String lbusername=rBundle.getString("login_username");
String lbpassword=rBundle.getString("login_password");
request.setAttribute("username", lbusername);
request.setAttribute("password", lbpassword);
System.out.println(county);
System.out.println(locale);
request.getRequestDispatcher("Guojihua.jsp").forward(request, response);