Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用空路径参数调用REST url_Java_Rest - Fatal编程技术网

Java 使用空路径参数调用REST url

Java 使用空路径参数调用REST url,java,rest,Java,Rest,服务器:Wildfly 8 REST包:javax.ws.rs* 同时尝试使用访问以下rest服务 http://localhost:8070/RestSample-war/rest/bean/getall/sam它工作得很好,但在使用空路径参数时 http://localhost:8070/RestSample-war/rest/bean/getall/,它抛出以下错误 @GET @Path("getall/{name: .*}") @Produces("application/json")

服务器:Wildfly 8

REST包:javax.ws.rs*

同时尝试使用访问以下rest服务
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/

你能试着去掉空白吗

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

更好的设计是有两个不同的方法映射到不同的URL。@ThorstenSchiffer,你的观点是有效的,但在某些情况下是必需的,所以我想知道为什么这个正则表达式解决方案不起作用。但该解决方案在2012年、2013年早期关于空路径参数的大量stackoverflow问题中可用。该选项是否已被去除润滑脂?