1. @GetMapping("{id}")
    2. @ResponseBody
    3. public String info(@PathVariable("id") String id){
    4. return id;
    5. }

    通过NativeWebRequest获取URL中id参数

    1. String id = ((Map<String, String>) nativeWebRequest.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST)).get("id");