I am trying to embed path's in a class like so:
@Service("adminSvc")
@Path("/admin")
public class AdminSvc {
@GET
pub开发者_如何学Golic String getStuff(){
return "stuff";
}
@GET
@Produces(MediaType.TEXT_HTML)
@Path("/stuff")
public String moreStuff(){
return "even more stuff";
}
}
the goal is to have a page return for admin, then return a page for /admin/stuff this unfortunately is returning a 405 when i attempt it, but according to:
Overriding @Path at Jerseyit should be working fine. Any ideas?
I've copied and pasted that code (excluding the @Service) into one of my Jersey (1.7) projects and it works as intended.
/admin returns "stuff"
/admin/stuff returns "even more stuff"
If yout get a 405 Method Not Allowed
this means you use an Accept
header that doesn't match MediaType.TEXT_HTML
which probably is only a shortcut for text/html
. So check your HTTP request.
What is the value of @Produces(...)
for your whole Resource?
精彩评论