@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 Exception{}
只有设置了@RequestParam(required = false)时,即使没有attributeName这个变量也会进入到此方法,若required=true时,缺少此参数是不会进入到这个方法的,默认为true