码迷,mamicode.com
首页 > 编程语言 > 详细

修改浏览器语言环境

时间:2015-06-12 00:56:01      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

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

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     }

 

修改浏览器语言环境

标签:

原文地址:http://www.cnblogs.com/sherrykid/p/4570502.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!