@RequestMapping(method = RequestMethod.POST, value = "/search") SjesPage<TurnTable> findTurnTables(@RequestParam(value = "startDate", required = false) String startDate, @RequestParam(value = "endDate", required = false) String endDate, Pageable pageable)
当 startDate为null 时候 会报错: HTTP Status 400 - Required String parameter 'xx' is not present
required = false 当 startDate不存在时候赋值 null
解决:
改 required = true,也可以不写, 为空时候 startDate 手动赋值 “ ”
if(StringUtils.isEmpty(startDate)|| StringUtils.isEmpty(endDate)){ return turnTableApiClient.findTurnTables("", "", new PageRequest(page - 1, limit)); }