修改浏览器语言环境

想要修改浏览器的语言环境,要点在于知道浏览器的语言环境是如何读取的

jsp:

1 <html:link action="/test/LocationDo?language=zh&country=CN">中文</</span>html:link>
2 
3 <html:link action="/test/LocationDo?language=en&country=US">英文</</span>html:link>

Action:

 1 private StringlocationDo(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) {
 2        String language =request.getParameter("language");
 3        String country =request.getParameter("country");
 4 
 5        Locale locale = getLocale(request);
 6 
 7        if(StringUtils.isNoneBlank(language)&&StringUtils.isNoneBlank(country)){
 8            locale =new Locale(language, country);
 9        } else if (!StringUtils.isEmpty(language)){
10            locale =new Locale(language, "");
11        }
12 
13        HttpSession session =request.getSession();
14        session.setAttribute(Globals.LOCALE_KEY,locale);
15 
16 
17        return "success";
18     }

 

posted @ 2015-06-11 23:20  csnmd  阅读(691)  评论(0编辑  收藏  举报