【发布时间】:2013-04-19 14:12:31
【问题描述】:
我尝试使用 HTTPS 和基本身份验证在 Grizzly(2.2.21) 服务器上运行 Jersey(1.17) 资源,并让除资源之外的一切正常工作。
@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”。
我也试过了
@Path("/")
public class Helloworld {
@GET
@Path("/helloworld")
public String helloworld() {
return "asdf";
}
}
和
@Path("/helloworld")
public class Helloworld {
@GET
public String helloworld() {
return "asdf";
}
}
在这两种情况下,每个请求我都会在 Firebug 中得到 404。
有人有解决方案吗? 谢谢
编辑:
要创建服务器等,我使用此示例代码(没有服务器信任库): https://svn.java.net/svn/jersey~svn/trunk/jersey/samples/https-clientserver-grizzly/src/main/java/com/sun/jersey/samples/https_grizzly/
【问题讨论】:
-
您是否尝试过查询 localhost:port/helloworld/helloworld? (Ed - 当然问题中给出了你们中的第一个版本......)
-
@Fildor 使用我得到的第一个版本: localhost:port/helloworld/helloworld -> "asdf2" localhost:port/helloworld/helloworld/ -> 404 localhost:port/helloworld/helloworld/something - > “asdf2”
-
请分享注册/初始化部分代码
-
@geozwey 请尝试将此行添加到初始化代码中:registration.addMapping("/*");