var url=new String('../../bo/match/update/weight/'+leagueAliase);
//对整个url进行编码,leagueAliase是接收中文汉字的变量,有一个奇怪的问题是要使用encodeURL对url进行两次编码,不知道为什么。以下是我用ajax提交的实例。
$.ajax({url:encodeURI(encodeURI(url)),
type:"POST",
data:{weight:weightV},
dataType:"text",
success:function(data){
console.log("data "+data);
parent.$.messager.progress("close");
dcbf_dataGrid.datagrid("load");
},
complete:function(XMLHttpRequest, textStatus){
//alert(textStatus);
//alert(XMLHttpRequest.status);
//alert(XMLHttpRequest.readyState);
},
error:function(){
parent.$.messager.progress("close");
//showErrorInfor("修改");
}
});
在java后台中用URLDecoder.decode(league,"UTF-8"));对传递过来的变量进行解码(注:我这儿是spring mvc传值),即将@PathVariable String league中league接收到值用URLDecoder.decode(league,"UTF-8"));进行解码(注:我前面页面用的是UTF-8编码,即前后台编码与解码的字符节编码必须一致)。