使用空路径参数调用REST URL

时间:2016-02-17 12:09:22

标签: java rest

服务器:Wildfly 8

REST包:javax.ws.rs。*

尝试访问以下休息服务时使用 http://localhost:8070/RestSample-war/rest/bean/getall/sam它工作正常,但尝试使用空路径参数 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/

1 个答案:

答案 0 :(得分:0)

请你尝试删除空白

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