前端请求
var data = {id:101,name:"张三",LAY_TABLE_INDEX:1}//Student
$.ajax({
type: "post",
url: '/resourcemanage/update',
data: data,
// contentType: "application/json; charset=utf-8",
dataType: "json",
//async: false,
error: function(data) {
layer.alert("请求出错了!请联系管理员", {icon: 2});
return false;
},
success: function(data) {
if(data.state=="ok"){
layer.msg("更新成功");
layer.close(index);
table.reload('resourcemanage');
}else{
layer.alert(data.msg, {icon: 2});
}
}
});
Controller怎么接收?
Student student = getModel(Student.class);//接收失败{}
Student student = getBean(Student.class);//接收失败{}
Student student = getModel(Student.class,"");//抛异常 The model attribute LAY_TABLE_INDEX is not exists.
Student student = getBean(Student.class,true);//接收失败{}
String jsonStr = HttpKit.readData(getRequest());
Student student = JSON.parseObject(jsonStr,Student.class);//抛异常
后台信息:Parameter : id=102 name=张三 creusrcode= LAY_TABLE_INDEX=1
LAY_TABLE_INDEX是额外的参数,并不是Student的属性。
这个怎么接收呢?
如果是[{id:101,name:"张三"},{id:102,name:"李四"}]这种数组,又该如何接收?
getModel,getBean 多传了其他参数就不能接收了吗?