【发布时间】:2016-06-08 18:47:53
【问题描述】:
我正在尝试在 RestController 中获取请求 URL。 RestController 有多个用 @RequestMapping 注释的方法,用于不同的 URI,我想知道如何从 @RequestMapping 注释中获取绝对 URL。
@RestController
@RequestMapping(value = "/my/absolute/url/{urlid}/tests"
public class Test {
@ResponseBody
@RequestMapping(value "/",produces = "application/json")
public String getURLValue(){
//get URL value here which should be in this case, for instance if urlid
//is 1 in request then "/my/absolute/url/1/tests"
String test = getURL ?
return test;
}
}
【问题讨论】:
标签: java spring spring-boot