小编NRA*_*NRA的帖子

如何在Spring Boot RestController中获取请求URL

我试图在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;
   }
} 
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

31
推荐指数
4
解决办法
6万
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1