火狐浏览器URL中传中文参数乱码问题

火狐浏览器:前端页面传中文

<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");

原文地址:https://www.cnblogs.com/caogen1991/p/6049264.html