开发者

Jersey embedded @Path

开发者 https://www.devze.com 2023-03-30 11:15 出处:网络
I am trying to embed path\'s in a class like so: @Service(\"adminSvc\") @Path(\"/admin\") public class AdminSvc {

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 Jersey

it 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消