Using the residual path with "/"

Is there any difference between @Path with a value starting with and without /

I tested both use and everything is correct.

@Path("message")
public class MessageServices {

    @PUT
    @Path("sendsms")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces({MediaType.APPLICATION_JSON})
    public Response sendSms() {
        //....
    }

}



@Path("/message")
public class MessageServices {

    @PUT
    @Path("/sendsms")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces({MediaType.APPLICATION_JSON})
    public Response sendSms() {
        //....
    }

}
+4
source share
2 answers

I have never seen any difference. The documentation for @Path( http://docs.oracle.com/javaee/7/api/javax/ws/rs/Path.html ) says:

. URI - , . ApplicationPath. URI URI . URI "/" , URI , "/".

.

+7

:

@Path (/). JAX-RS URI , .

, , .

P.S. , -, JAX-RS. @Path

+1

All Articles