简体   繁体   中英

Jersey 404 on two Resource Classes with similar @Path annotations

I have a RESTful Web service, using Drop Wizard 0.8.5 with Jersey 2.21. I have a resource class with is annotated with:

@Path("/mysite/somepath")

This class contains various methods, such as @GETs, @PUTS, etc., all working just fine.

Now, I have another resource class that is annotated with @Path("/mysite") . Within this resource class I have a need to add a few methods annotated with paths such as the following:

@Path("/somepath/dothis")
@Path("/somepath/dothat")

The resource classes all register just fine. However, when I make a call to the second class I get a 404, as it appears Jersey is looking for these methods in my first class. Is there a way to resolve this issue, other than changing my @Path annotations to avoid this naming conflict?

Jersey presumes each class has unique @Path expression associated with it. If you want to use the same @Path variable to two different resources, you either use two different path names, or you can combine the two classes into one class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM