2016-11-08 35 views
0

我有2 GET請求的服務類像下面並在日誌中總是給我警告有關多資源的方法匹配請求RestEasy的多個資源路徑華林

@Path("/a") 
class Service{ 
    @Path("/{name}" 
    @GET 
    public A methodA(@PathParam("name") String name){return a;} 

    @Path("/status") 
    @GET 
    public B methodB(){return b;} 
} 

任何人可以有任何想法,爲什麼就是它?? 我使用的休息,容易版本3.0.8 4.XX

+0

'/ status'不同於'/ {name}'在'PathParam''name'中傳遞字符串'status'的地方? – pleft

+1

當你點擊url'/ a/status'你想要你的應用程序去哪裏?可以說當name ='status' – kuhajeyan

+0

感謝您的評論。它的工作方式是現在實施,但**我的問題是爲什麼它會爲此拋出警告?**我沒有得到。一個是靜態路徑,另一個是可變路徑。另外一種資源方法有爭論,另一種則不適用。 – Lipu

回答

0

考慮我在你上面的問題的評論,我想我的控制器改寫爲這樣的:

@Path("/a") 
class Service{ 
      @Path("/{name}" 
      @GET 
      public ResponseEntity methodA(@PathParam("name") String name){ 
       if("status".equals(name) { 
        return new ResponseEntiry(b, OK); 
       } else { 
        return new ResponseEntiry(a, OK); 
       } 
      } 
}