前端页⾯传来数组,后台⽤对象集合list接收数据的写法//保存页⾯显⽰应⽤
$("#save").click(function(){
var data = [{"applicationtypeid":"65","applicationsystemid":"30"},{"applicationtypeid":"65","applicationsystemid":"31"}];
$.ajax({
url: "${ctx}/applicationuser/save",
type: "POST",
contentType : 'application/json;charset=utf-8', //设置请求头信息
dataType:"json",
data: JSON.stringify(data),    //将Json对象序列化成Json字符串,JSON.stringify()原⽣态⽅法
success: function(result){
console.log("保存页⾯显⽰应⽤",result);
},
nodejs字符串转数组error: function(res){
layer.msg("操作失败!",{icon: 5,time:2000});
}
});
});
/**
* 保存页⾯显⽰应⽤
*/
@RequestMapping("/save")
@ResponseBody
/
/@RequiresPermissions("applicationuser:save")
public JSONObject saveApplicationUser(@RequestBody List<ApplicationUserEntity> applicationUserList){
return applicationUserService.saveApplicationUser(applicationUserList);
}
第⼆种写法
/**
* 保存页⾯显⽰应⽤
*/
@RequestMapping("/save")
@ResponseBody
public JSONObject saveApplicationUser(@RequestBody String str ,HttpServletRequest request){
List<ApplicationUserEntity> applicationUserList = JSONArray.parseArray(str, ApplicationUserEntity.class);
return applicationUserService.saveApplicationUser(applicationUserList,request);
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。