HTTP Status 400

来源:互联网 发布:汽车外形设计软件 编辑:程序博客网 时间:2024/06/05 20:35
@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));}