休息 - RESTEasy 切割@Path 的尾部斜线

标签 rest jax-rs resteasy

RESTEasy 看起来会忽略尾部斜杠,因此我无法编写带有和不带有尾部斜杠的两个不同的 Web 服务,此示例显示:

@Path("foo")
public class TestClass {

    @GET
    @Path("/bar")
    public Response bar1() {
        ...
    }

    @GET
    @Path("/bar/")
    public Response bar2() {
        ...
    }
}

使用 RESTEasy,对/foo/bar 和/foo/bar/的 GET 请求由 bar2() 处理。考虑到 RFC3986 和 JAX-RS 规范,我不明白为什么要这样处理。这可能是 RESTEasy 的问题还是我监督的问题?

最佳答案

这是什么JAX-RS specification

3.7 资源方法请求匹配

3.7.3 将 URI 模板转换为正则表达式

  1. URI encode the template, ignoring URI template variable specifications.
  2. Escape any regular expression characters in the URI template, again ignoring URI template variable specifications.
  3. Replace each URI template variable with a capturing group containing the specified regular expression or ‘([^/]+?)’ if no regular expression is specified.
  4. If the resulting string ends with ‘/’ then remove the final character.
  5. Append ‘(/.*)?’ to the result.


当我阅读它时,RESTEasy 正确地实现了规范。

关于休息 - RESTEasy 切割@Path 的尾部斜线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15196698/

相关文章:

asp.net-mvc-3 - 在 IIS 7/7.5 中注册 PATCH HTTP 动词

java - REST with JAX-RS - 处理长时间运行的操作

java - 如何使用 postman 调试我的其余 webservices maven 项目?

java - JaxRS 从服务器创建并返回 zip 文件

ssl - 如何在 JAX-RS 客户端上以编程方式覆盖密码/协议(protocol)

json - @JsonIgnore 和 @JsonBackReference 被忽略

java - Resteasy客户端: @CookieParam replicates its value on every request

resteasy - 在 jboss AS 7.1 上调试 JAX-RS 服务注册

rest - 如何使用 REST 连接云服务中的虚拟机

http - 分布式 REST 队列的可用实现