zoukankan      html  css  js  c++  java
  • jquery post 中文乱码解决方案

    前台post请求的时候对发送的数据进行encodeURIComponent()编码
    例如:
    var transactType= $("#transactType").attr("value");
    var content=encodeURIComponent($("#content").html());
    var title=encodeURIComponent($("#title").val());
    $.post(      
    "${path}/transact!addTransact.action",
     {"content":content,"title":title},
     function(data){        
       if(data=='1'){           
        alert("保存成功!");           
        DG.cancel();          
      }else{           
        alert("保存失败!");        
      }
    }
    );
    后台:
    用UTF-8转译
    transactType = URLDecoder.decode(getStringParameter("transactType"),"UTF-8");
    content =  URLDecoder.decode(getStringParameter("content"),"UTF-8");
    title =  URLDecoder.decode(getStringParameter("title"),"UTF-8");
    即可解决jQuery post请求中文乱码问题。
  • 相关阅读:
    android 源码
    android 保护
    电池信息 显示
    RGB、HSB、HSL 互相转换算法
    网页美工
    css 设计标准
    js 封闭 小结
    格式转换工具
    网页设计规范
    瀑布流分析
  • 原文地址:https://www.cnblogs.com/tofight/p/2805083.html
Copyright © 2011-2022 走看看