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/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
    如果文中有错误,欢迎指出。以免更多的人被误导。
    欢迎留言交流。
  • 相关阅读:
    Visual Studio 20年
    cocos2d-x 重力感应 加速器的使用
    大规模高性能站点架构设计思路整理
    MySQL
    drools 的一个小demo
    springboot使用hibernate validator校验
    mybatis JdbcTypeInterceptor
    ColorPic 一套簡單好用的顏色選擇器!
    WebStorm ES6 语法支持设置
    css中单位em和rem
  • 原文地址:https://www.cnblogs.com/robertsun/p/4149986.html
Copyright © 2011-2022 走看看