这就是我要做的事情:
@Path("/finder")
public class Finder {
@Path("/{name}")
public Proxy find(@PathParam("name") String name) {
Object found = /* some object found by name */
return new Proxy(found);
}
}
public class Proxy {
private Object obj;
public Proxy(Object found) {
this.obj = found;
}
@GET
@Path("/")
public String info() {
return /* some meta-information about the object */
}
@Path("/")
public Object passthru() {
return this.obj;
}
}
我正在尝试启用:
GET /finder/alpha -> Proxy.info()
GET /finder/alpha/something -> obj.something()
我走对了路吗?同时,泽西岛说:
WARNING: A sub-resource method, public final java.lang.String com.XXX.Proxy.info(),
with URI template, "/", is treated as a resource method
答案 0 :(得分:2)
上述代码一切正常,但我@Path("/")
处不需要info()
注释。