1.正常情况下,你可能会这样写:
@PostMapping("/delete") @ApiOperation("Delete list data") @ResponseStatus(HttpStatus.OK) @ResponseBody public DBUpdateStatus deleteTestCaseDatas( List<TestCaseInfo> testCaseInfoList){ try { testLinkService.deleteTestCaseList(testCaseDetailInfoList); return DBUpdateStatus.Success; }catch (Exception e){ return DBUpdateStatus.Fail; } }
但是这样写,其实会报错:
那么,正确的方式应该怎样写呢:
@PostMapping("/delete") @ApiOperation("Delete list data") @ResponseStatus(HttpStatus.OK) @ResponseBody public DBUpdateStatus deleteTestCaseDatas(@RequestBody List<TestCaseInfo> testCaseInfoList){ try { testLinkService.deleteTestCaseList(testCaseDetailInfoList); return DBUpdateStatus.Success; }catch (Exception e){ return DBUpdateStatus.Fail; } }
直接在该 含List参数的对象上,添加一个无参构造器,解决!
但并不知道原理是什么,路过的大神求解答~~
标签:return,Springboot,HttpStatus,deleteTestCaseList,List,controller,api,DBUpdateStat From: https://www.cnblogs.com/pingguomang/p/17495762.html