gpt4 book ai didi

rest - 对 Jersey 中不匹配的 REST 方法使用默认方法

转载 作者:行者123 更新时间:2023-12-04 22:37:08 27 4
gpt4 key购买 nike

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

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

我怎样才能做到这一点?

BR,

塞尔坎C

最佳答案

@Path("/{default: .*}")

这适用于:
  • http://example.com/someUnexpectedPath
  • http://example.com/someUnexpectedPath/withAdditionalSubPaths
  • http://example.com/someUnexpectedPath/withAdditionalSubPaths?andParams=whatever
  • 关于rest - 对 Jersey 中不匹配的 REST 方法使用默认方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4104034/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com