@PathVariable :主要用于动态绑定url
案例
//@PathVariable("id") String videoId "id"必须与url中的{id}保持一致@PostMapping("/{id}/like")public ResponseEntity<Long> likeComment(@PathVariable("id") String videoId) {try {Long likeCount = this.videoService.likeComment(videoId);if (likeCount != null) {return ResponseEntity.ok(likeCount);}} catch (Exception e) {e.printStackTrace();}return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();}
@RequestParam :将请求参数绑定到你控制器的方法参数上(是springmvc中接收普通参数的注解)
- 案例
@RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize
- 案例
@RequestBody :可以绑定自定义的对象类型的参数
- 案例
@RequestBody Map<String, String> param;param.get("nickname");
- 案例
