用字符编码处理中文乱码问题,js向action中传值时

来源:互联网 发布:云杉网络 融资 编辑:程序博客网 时间:2024/06/05 05:37




url 传值时

java中

编译

name = URLEncoder.encode("哈哈哈", "UTF-8");

        必要的时候:name = URLEncoder.encode(URLEncoder.encode(userName, "UTF-8"));转两次

解码
URLDecoder.decode(str,"utf-8")


js中

编译

encodeURIComponent(encodeURIComponent(str)); 
解码
var type = decodeURIComponent(data); js中