Java 有人在resteasy中遇到不可用的根路径吗

Java 有人在resteasy中遇到不可用的根路径吗,java,resteasy,Java,Resteasy,我正在使用RESTEasy编写一个WebService示例,并设置根资源路径。但我发现,即使url中没有根路径,我仍然可以获得正确的资源 主要功能代码: NettyJaxrsServer netty = new NettyJaxrsServer(); ResteasyDeployment deploy = new ResteasyDeployment(); List<Object> resources = new ArrayList<Object>(

我正在使用RESTEasy编写一个WebService示例,并设置根资源路径。但我发现,即使url中没有根路径,我仍然可以获得正确的资源

主要功能代码:

   NettyJaxrsServer netty = new NettyJaxrsServer();
    ResteasyDeployment deploy = new ResteasyDeployment();
    List<Object> resources = new ArrayList<Object>();
    resources.add(new UserService());
    deploy.setResources(resources);
    netty.setDeployment(deploy);
    netty.setPort(8180);
    netty.setRootResourcePath("/hello/");
    netty.setSecurityDomain(null);
    netty.start();
对于代码,url/user可以正常工作,无需添加根路径/hello。我检查了源代码;它自己添加根路径

源代码:

public static String getEncodedPathInfo(String path, String contextPath)
{
    if(contextPath != null && !"".equals(contextPath) && path.startsWith(contextPath))
        path = path.substring(contextPath.length());
    return path;
}
我的问题是RESTEasy为什么要这么做?我不明白

public static String getEncodedPathInfo(String path, String contextPath)
{
    if(contextPath != null && !"".equals(contextPath) && path.startsWith(contextPath))
        path = path.substring(contextPath.length());
    return path;
}