SpringBoot项目中@RequestParam、@PathVariable、@Param的区别?

时间:2024-10-06 07:16:13
/** * 根据查询条件分页查询品牌信息 * @param key * @param page * @param rows * @param sortBy * @param desc * @return */ @GetMapping("page") public ResponseEntity<PageResult<Brand>> queryBrandsByPage(@RequestParam(value = "key",required = false)String key, @RequestParam(value = "page",defaultValue = "1")Integer page, @RequestParam(value = "rows",defaultValue = "5")Integer rows, @RequestParam(value = "sortBy",required = false)String sortBy, @RequestParam(value = "desc",required = false)Boolean desc) { PageResult<Brand> result = this.brandService.queryBrandsByPage(key, page, rows, sortBy, desc); if (CollectionUtils.isEmpty(result.getItems())) { return ResponseEntity.notFound().build(); } return ResponseEntity.ok(result); }