springboot處理 json 轉換成 實體物件
阿新 • • 發佈:2019-02-10
可以使用@RequestBody
@PostMapping("/add") public Result add(@RequestBody LogisticsDemand demand){ if(demand.getRefreshTime()==null){ demand.setRefreshTime(new Date()); } int result = logisticsDemandService.insertdemand(demand,demand.getOrders()); if(result>0){ return Result.success("儲存成功!"); }else{ return Result.error(501,"儲存失敗!"); } }
時間格式的處理
@JsonFormat( pattern="yyyy-MM-dd HH:mm:ss")
private Date timeLimit;
參考: