首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grizzly Jersey -只有@Path("/")有效

Grizzly Jersey -只有@Path("/")有效
EN

Stack Overflow用户
提问于 2013-04-19 22:12:31
回答 1查看 688关注 0票数 0

我尝试使用HTTPS和Basic Auth在Grizzly(2.2.21)服务器上运行Jersey(1.17)资源,并获得除资源之外的所有内容。

代码语言:javascript
复制
@Path("/")
public class Helloworld {

    @GET
    public String helloworld2() {
        return "asdf2";
    }

    @Path("helloworld")
    @GET
    public String helloworld() {
        return "asdf";
    }
}

是的,这只是Helloworld的例子,它仍然让我抓狂。我可以访问localhost:port/,它工作得很好,但是localhost:port/somethingother也返回"asdf2“。尤其是localhost:port/helloworld也返回"asdf2“。

我也试过

代码语言:javascript
复制
@Path("/")
public class Helloworld {

   @GET
   @Path("/helloworld")
   public String helloworld() {
      return "asdf";
   }
}

代码语言:javascript
复制
@Path("/helloworld")
public class Helloworld {

   @GET
   public String helloworld() {
      return "asdf";
   }
}

在这两种情况下,每次请求我都会在Firebug中获得404。

有人有解决方案吗?Thx

编辑:

为了创建服务器等,我使用以下示例代码(没有服务器信任库):https://svn.java.net/svn/jersey~svn/trunk/jersey/samples/https-clientserver-grizzly/src/main/java/com/sun/jersey/samples/https_grizzly/

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-24 23:25:07

registration.addMapping("/*");添加到我的初始化代码中起作用了。

非常感谢alexey

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16106676

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档