qq_31505613
jeryzr
2017-12-07 13:47

前端向后端传递复杂json类型遇到的问题

20
  • spring
  • 前端
  • json

$("#btn").click(function(){
var data={
header:{appId:'erghege',secret:'gergergeg'},
user:{name:'jery',pasword:'1132332'}
}
$.ajax({
url:"testjson.spring",
data:data,
dataType:"json",
contentType:"application/json",
success:function(){
}
});
我封装了一个类
public class Meta {
private User user;
private Header header;
//......
}
@RequestMapping("/testjson")
@ResponseBody
public Map logout(Meta meta){
Map map = new HashMap();
map.put("status", "1");
return map;
}
让Meta 接收前台传递过来的 json,报Invalid property 'header[appId]' of bean class [com.test.Meta]: Property referenced in indexed property path 'header[appId]' is neither an array nor a List nor a Map; returned value was [erghege]
有什么方法解决一下么

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答