问题描述:

I have a following jersey class .

@Path("/static1/static2")

public class DoStuff {

@POST

@Path("/static3")

@Consumes(MediaType.APPLICATION_XML)

@Produces("application/xml")

public Response validation(String inputXML){

so my url is localhost/static1/static2/static3 and I get a 200

my goal is to have a URL that is

localhost/static1/{variable}/static2/static3

I tried modifying my class in the following way

@Path("/static1/{variable}/static2")

public class DoStuff {

@POST

@Path("/static3")

@Consumes(MediaType.APPLICATION_XML)

@Produces("application/xml")

public Response validation(String inputXML){

but I keep getting a 404 , what am I doing wrong ?

网友答案:

The problem seems to be with the last path segment static3.{format}. Try the following:

@Path("/static1/{variable}/static2")
    public class DoStuff {

    @POST
    @Path("/{segment3:static3.*}")
    @Consumes(MediaType.APPLICATION_XML)
    @Produces("application/xml")
    public Response validation(@PathParam("variable") String variable,
                               @PathParam("segment3") String segment3, 
                               String inputXML) {
       ...............
    }
相关阅读:
Top