1、下拉列表选择生效函数
function changeSessionMarketType(marketType) { var params = {marketType:marketType} $.ajax({ type: "POST", url: "./adminHome/changeSessionMarketType.html", data: params, success: function(msg){ window.location.reload(); alert("切换成功!"); } }); } function changeSessionLanguageType(languageType) { var currentUrl = window.location.href; if(0 == languageType){ window.location.href = "./adminHome/main.html?lang=zh_CN"; /* if(currentUrl.indexOf("?") != -1){ window.location.href = currentUrl + "&lang=zh_CN"; }else{ window.location.href = currentUrl + "?lang=zh_CN"; } */ }else if(1 == languageType){ window.location.href = "./adminHome/main.html?lang=en_US"; /* if(currentUrl.indexOf("?") != -1){ window.location.href = currentUrl + "&lang=en_US"; }else{ window.location.href = currentUrl + "?lang=en_US"; } */ } }
<% String role = (String)request.getSession().getAttribute("ROLE");//当前登录用户的权限 Locale locale = (Locale)request.getSession().getAttribute("LOCALE");//当前登录用户的语言 Integer marketType = (Integer)request.getSession().getAttribute("marketType");//当前登录用户的APP RequestContext requestContext = new RequestContext(request); Locale myLocale = requestContext.getLocale(); String language = myLocale.getLanguage(); %>
<div class="account_meta account_language"> <spring:message code="language" />: <select id="languageType" onchange="changeSessionLanguageType(this.options[this.options.selectedIndex].value)"> <option value="0" <%if(language.contains("zh")){%> selected<% } %>> <spring:message code="language.cn" /> </option> <option value="1" <%if(language.contains("en")){%> selected<% } %>> <spring:message code="language.en" /> </option> </select> <!-- Locale: ${pageContext.response.locale} --> </div> <div class="account_meta account_language"> <spring:message code="switch_app" />: <select id="marketType" onchange="changeSessionMarketType(this.options[this.options.selectedIndex].value)"> <option value="0" <%if(marketType.intValue()==0){%> selected<% } %>>FCA</option> <option value="1" <%if(marketType.intValue()==1){%> selected<% } %>>SCB</option> </select> </div>