用戶名爲中文時,火狐、google瀏覽器無問題,但IE有亂碼問題:javascript
問題代碼: html
<a href="member!sysLogin.do?name='${member.uname }'" target="_blank"/>登陸</a>
超連接形式的傳參,都是Get方式!
java
Java代碼 瀏覽器
public String sysLogin(){ try{ name=new String(name.getBytes("iso-8859-1"),"utf-8"); int r = this.memberManager.loginbysys(name); if(r==1){ return "syslogin"; } this.msgs.add("登陸失敗"); }catch(RuntimeException e){ this.msgs.add(e.getMessage()); } catch (UnsupportedEncodingException e) { this.msgs.add(e.getMessage()); } return this.MESSAGE; }
修改爲功:this
Java代碼 google
<a href="javascript:toSysLogin('${member.uname }');" />登陸</a> function toSysLogin(name){ var uriname="member!sysLogin.do?name="+name; window.open( encodeURI(uriname)); }
Java代碼 spa
public String sysLogin(){ try{ this.setName(java.net.URLDecoder.decode(name, "UTF8"));// 此處轉碼 name=new String(name.getBytes("iso-8859-1"),"utf-8"); int r = this.memberManager.loginbysys(name); if(r==1){ return "syslogin"; } this.msgs.add("登陸失敗"); }catch(RuntimeException e){ this.msgs.add(e.getMessage()); } catch (UnsupportedEncodingException e) { this.msgs.add(e.getMessage()); } return this.MESSAGE; }