$.ajax({
url : "${ctx}/exeChange/getDataSource.html?deviceId="+deviceId+"&a="+new Date().getTime() ,//url
contentType : "application/json",//application/xml
processData : true,//contentType为xml时,些值为false
type:"POST",
dataType : "json",//json--返回json数据类型;xml--返回xml
data:{
tag : "tag123"
} ,
success : function(data) {
if(data==null){
alert(data.exSysName);
},
error : function(e) {
alert("连接服务器失败...");
}
});
url : "${ctx}/exeChange/getDataSource.html?deviceId="+deviceId+"&a="+new Date().getTime() ,//url
contentType : "application/json",//application/xml
processData : true,//contentType为xml时,些值为false
type:"POST",
dataType : "json",//json--返回json数据类型;xml--返回xml
data:{
tag : "tag123"
} ,
success : function(data) {
if(data==null){
alert(data.exSysName);
},
error : function(e) {
alert("连接服务器失败...");
}
});
}
以上是js代码,传数据过去后,由于编码是iso8859-1,所以会乱码,转成utf-8就好了。如果需要result返回数据,要使用注解@responsebody,但是这个时候返回的数据类型任然是8859-1,也就是说会乱码,所以我建议直接用response.out.print来返回,可以设置字符编码,也就不会乱码了。