js、java传值编码

it2022-05-05  101

一、请求使用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"); 就可以取得正确值

转载于:https://www.cnblogs.com/robertsun/p/4149986.html


最新回复(0)