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"); 就可以取得正确值

posted on 2014-12-07 22:12  robertsun  阅读(252)  评论(0编辑  收藏  举报

导航