2016-02-17 47 views
0

服務器:Wildfly 8個調用REST URL與空路徑PARAM

REST包裝:javax.ws.rs *

雖然嘗試與 http://localhost:8070/RestSample-war/rest/bean/getall/sam它工作正常訪問下面休息的服務,但在空路徑PARAM嘗試像 http://localhost:8070/RestSample-war/rest/bean/getall/,它會引發以下錯誤

@GET 
@Path("getall/{name: .*}") 
@Produces("application/json") 
public Object Getall(@PathParam("name") String customerName) { 
    if(customerName !=null){ 
     //return specific customer detail 
    }else{ 
    //return all customer detail 
    } 
} 

錯誤:

17:18:04,637 WARN [org.jboss.resteasy.core.ExceptionHandler] (default task-37) 
failed to execute: javax.ws.rs.NotFoundException: Could not find resource for 
full path: http://localhost:8070/RestSample-war/rest/bean/getall/ 
+0

更好的設計將有被映射到不同的URL兩種不同的方法。 –

+0

@ThorstenSchiffer,你的觀點是有效的,但在某些情況下它是必需的,所以我想知道爲什麼這個正則表達式解決方案不起作用。但是這個解決方案在2012年之前的2013年有很多關於空路徑參數的stackoverflow問題。這個選項被取消了嗎? – Jeevanantham

回答

0

能不能請你刪除空格

@Path("getall/{name:.*}") 
+0

它不工作 – Jeevanantham