当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Jersey @Path mapping queries

问题描述:

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) {
       ...............
    }
分享给朋友:
您可能感兴趣的文章:
随机阅读: