@GetMapping("{id}")
@ResponseBody
public String info(@PathVariable("id") String id){
return id;
}
通过NativeWebRequest获取URL中id参数
String id = ((Map<String, String>) nativeWebRequest.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST)).get("id");