Spring Rest POST Json RequestBody Content type not supported

后端 未结 14 1688
粉色の甜心
粉色の甜心 2020-12-05 05:58

When I try to post new object with post method. RequestBody could not recognize contentType. Spring is already configured and POST could work with others objects, but not th

14条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 06:32

    specify @JsonProperty in entity class constructor like this.

    ......
    ......
    ......
    
     @JsonCreator
     public Location(@JsonProperty("sl_no") Long sl_no, 
              @JsonProperty("location")String location,
              @JsonProperty("location_type") String 
              location_type,@JsonProperty("store_sl_no")Long store_sl_no) {
      this.sl_no = sl_no;
      this.location = location;
      this.location_type = location_type;
      this.store_sl_no = store_sl_no;
     } 
    .......
    .......
    .......
    

提交回复
热议问题