天天看点

@PathVariable和@RequestParam的区别

@PathVariable用来获取URL路径中的变量

@RequestParam用来获取请求变量

eg:

localhost:8080/v1/users/111?attributeName=USER_ACCOUNT      

获取以上请求路径中的111使用@PathVariable

获取attributeName变量使用@RequestParam

@GetMapping("/{attributeValue}")
@ResponseBody
public ReturnResult select(@PathVariable String attributeValue,
            @RequestParam(required = false) String attributeName) throws