火狐瀏覽器:前端頁面傳中文
<span data-bind=" check_action:'roleMenuPriv'"> <a data-bind="attr:{href:'#pages/systems/roles/authorization?uuid=' + $row.uuid+'&name='+encodeURI(encodeURI("此處為要傳的中文字符"))},disable:false">權限</a>|
</span>
下個頁面取該參數時,再進行兩次解碼
name = decodeURI(decodeURI(name));
此時name為正常中文字符,不亂碼
切記,要進行兩次轉碼操作,取值的時候也要進行兩次解碼操作,只編碼一次的話,解碼后依然是亂碼
編碼:name = encodeURI(encodeURI("此處為要傳的中文字符"));
解碼:name = decodeURI(decodeURI(name));
如果是后台解碼的話,采用下面的方法:
java.net.URLDecoder.decode(name,"UTF-8");