RequestParam: Annotation which indicates that a method parameter should be bound to a web request parameter.
PathVariable: Annotation which indicates that a method parameter should be bound to a URI template variable.
RequestParam获取的是请求web参数,入下图中?之后的参数
http://localhost:8080/ssm/book/queryAll?offset=1&limit=2
@RequestMapping(value = "/queryAll", method = RequestMethod.POST)
private String queryAll(Model model, @RequestParam("offset") int offset, @RequestParam("limit") int limit)
PathVariable获取的是URI中的参数,
http://localhost:8080/ssm/book/1003/appoint
@RequestMapping(value = "/{bookId}/appoint", method = RequestMethod.POST, produces = {
"application/json; charset=utf-8" })
@ResponseBody
private Result<AppointExecution> appoint(@PathVariable("bookId") Long bookId, @RequestParam("studentId") Long studentId)