最簡單的兩種寫法,加或不加@RequestParam註解app
@RequestMapping("/list") public String test(int userId) { return "list"; } @RequestMapping("/list") public String test(@RequestParam int userId) {
return "list"; }
區別: ui
用法以下:spa
@RequestMapping("/list") public String test(@RequestParam(value = "userId", defaultValue = "0", required = false) int userId) { return "list"; }