@RequestMapping(value = "/done/{pageNum}/{pageSize}")
public ResponseData done(@PathVariable int pageNum, @PathVariable int pageSize, @RequestParam String busSerial,
@RequestParam String proposer) {
ResponseData res = new ResponseData();
try {
res.setCode(ErrorEnum.SUCCESS.getCode());
res.setMsg(ErrorEnum.SUCCESS.getMessage());
res.setData(leaderService.doneList(pageNum, pageSize, busSerial, proposer));
} catch (Exception e) {
e.printStackTrace();
res.setCode(ErrorEnum.FAILED.getCode());
res.setMsg(ErrorEnum.FAILED.getMessage());
}
return res;
}
as above, pageNum and pageSize are required parameters. BusSerial and proposer are optional query parameters.
enter http://localhost:8088/leader/done/1/5 to get all the results
enter http://localhost:8088/leader/done/1/5?busSerial=&proposer= to get all the results
enter http://localhost:8088/leader/done/1 The result of / 5?busSerial=1&proposer=1 is that busSerial is 1in all the results. The result when proposer is 2.
but my above code can not be realized, have you ever written a big boss to teach it? How to set that kind of optional parameter?
(I can do this by passing a structure in the POST method, but this is a pure query interface and I don"t want to use POST)