springmvc后台使用@RequestBody注解接收ajax传值

后台代码:


@ResponseBody

@RequestMapping(method = RequestMethod.POST,value = "/create")

public Map create(@RequestBody LPEntity lp){

System.out.println(lp);

Map res = new HashMap<>();

res.put("a", lp);

return res;

 }

}



前端ajax代码:

var obj = {"id":"ID101010","deviceCode":"100100600","name":"graphId101010"};

      $.ajax({

      url:url,

      type:'post',

      dataType:'json',

      data:JSON.stringify(obj),

      contentType:"application/json",

      success:function(res){

      debugger;

      console.log(res);

      }

      });

你可能感兴趣的:(springmvc后台使用@RequestBody注解接收ajax传值)