【问题标题】:Jersey Path Param : Multiple backslash separated paramJersey Path Param:多个反斜杠分隔的参数
【发布时间】:2014-05-13 19:16:26
【问题描述】:
@Path("/assetViewCount/{path}")

上面的注释可用于将 myValue 检索到 path 中,以获取像 /assetViewCount/myValue 这样的 url。

如何从路径中的 /assetViewCount/myValue/nextValue 获取 myValue/nextValue

【问题讨论】:

  • 你能提供一些真实的例子吗?您是否试图找到返回 2 个不同 thingsassetViewCount。这两个值之间是否存在某种关系?
  • 不是两个不同的东西,基本上这个 ${path} 可以是类似 myFolder/subFolder/myFile.ext 的文件路径

标签: java rest jersey jersey-2.0 path-parameter


【解决方案1】:

实际上我找到了解决问题的方法,下面的注释给出了 /assetViewCount/ 到 {path} 之后的任何内容

@Path("/assetViewCount/{path:.*}")

【讨论】:

    【解决方案2】:

    您可以像这样在 Path 中使用嵌入参数:

    @Path("/assetViewCount/{path}/nextValue")
    

    【讨论】:

    • 对于像 /assetViewCount/myValue/nextValue 这样的 url,它会给我 {path} 中的 myValue,但我期待的是 /assetViewCount 之后进入 {path}
    • 确实需要@Path("/assetViewCount/{path}/{nextValue}")
    猜你喜欢
    • 2013-02-06
    • 2011-09-16
    • 1970-01-01
    • 2018-08-07
    • 1970-01-01
    • 1970-01-01
    • 2013-04-14
    • 1970-01-01
    • 2012-10-23
    相关资源
    最近更新 更多