在Jersey中为不匹配的REST方法使用默认方法

Ser*_*glu 4 rest jersey

我知道这不是"非常安静"但是,我想知道是否以及如何处理与我的REST资源中的任何方法都不匹配的所有请求(我想将这些请求代理到另一个服务器).例如,它可能是一种方法,如:

@GET 
@Path("*") 
public Response defaultMethod(@Context HttpServletRequest request, @Context HttpServletResponse response) 
{ 
    // do proxying here 
} 
Run Code Online (Sandbox Code Playgroud)

我该怎么做到这一点?

BR,

SerkanC

小智 9

@Path("/{default: .*}")
Run Code Online (Sandbox Code Playgroud)

这适用于:

  • http://example.com/someUnexpectedPath
  • http://example.com/someUnexpectedPath/withAdditionalSubPaths
  • http://example.com/someUnexpectedPath/withAdditionalSubPaths?andParams=whatever