springmvc 参数@RequestBody用例方法

前端代码

 $.ajax({
     type: "post",
     url: baseUrl + "handleSubmit",
     data: JSON.stringify(self.search),
     contentType: 'application/json',
     dataType: "json",
     success: function (data) {
          console.log(data)
     },
     error: function (error) {
         console.log('request failed', error);
     }
 });

Java后端代码

 @PostMapping(value = "handleSubmit")
 public Map handleSubmit(@RequestBody Entity entity) {
     Map m = new HashMap();
     m.put("entity",entity);
     return m;
 }

你可能感兴趣的:(Spring2.0,前端)