zoukankan      html  css  js  c++  java
  • js、java传值编码

    一、请求使用post方法不需要考虑编码问题。
    二、前后台统一编码,支持中文,不考虑编码;tomcat utf-8编码
    三、前后台编码不统一
     $.ajax({
                    url : "maintain/saveResourceInfoDESAction.action?imagePath="+imagePath,
                    type : 'get',// 数据发送方式
                    data:{"fTitle":fTitle,"htmlContent":htmlContent,"titleImgs":inputTitle.toString()},
                    async : true, //异步
                    dataType : 'json',
                    success : this.saveResInfoSuccess,
                    error: function(){alert('发表失败');}
                });

    imagePath  在 url中 需要  两次编码  encodeURI(encodeURI(imagePath));后台imagePath = URLDecoder.decode(imagePath,"UTF-8"); 才能取得正确值;
    fTitle  只需一次编码  encodeURI(fTitle)  后台imagePath = URLDecoder.decode(fTitle,"UTF-8"); 就可以取得正确值

    作者:robert
    出处:http://www.cnblogs.com/robertsun/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
    如果文中有错误,欢迎指出。以免更多的人被误导。
    欢迎留言交流。
  • 相关阅读:
    一条命令深度清理你的mac
    将以太坊封装为 ERC20
    golang subprocess tests
    go 笔记
    readme
    如何使用 channel
    修改vscode caipeiyu.writeCnblog ,简化博客发布
    thedao
    firefox 59 无法使用 pac 代理上网
    scrapy简单使用
  • 原文地址:https://www.cnblogs.com/robertsun/p/4149986.html
Copyright © 2011-2022 走看看