在使用Ajax向SpringMVC的Controller传递参数,普通参数可以直接传入,但是如果数据太多的话,最好在Controller中使用POJO接受参数,但是这个时候会包415错误,先写解决方案,再写底层原理
原本代码:
$.ajax({
url:"ajax",
data:{name:name},
dataType:"JSON",
method:"POST",
success:function(result){
alert(result.msg);
}
});
controller代码
在使用Ajax向SpringMVC的Controller传递参数,普通参数可以直接传入,但是如果数据太多的话,最好在Controller中使用POJO接受参数,但是这个时候会包415错误,先写解决方案,再写底层原理
原本代码:
$.ajax({
url:"ajax",
data:{name:name},
dataType:"JSON",
method:"POST",
success:function(result){
alert(result.msg);
}
});
controller代码