jax-rs What is the difference between using pathParam and queryParam in a web service?

0

If I have this code for a rest service in java JAX-RS

 @Path("/message")
 public class ExampleRestService {
 @GET
 @Path("/test/")
 public Response printeMessage(@PathParam("param") String mvar
        ){      
    String resp = "Mensaje restfull de respuesta es : "+ mvar ; 
    return Response.status(200).entity(resp).build();
}   

}

What implications does it have if the PathParam entry is changed to QueryParam, with respect to the generation of the resource url and the parameter step?

    
asked by Fabian Peñaloza 26.09.2018 в 06:00
source

1 answer

2

PathParam

It is a parameter that is part of the REST resource path. For example: link where 14 would be PathParam

QueryParam

It is a parameter that is in the query part, or query string. For example: link where id = 14 would be QueryParam

To your question of if you would change the url of the resource, you see that it does so since, apart from not being part of the route but of the query part, the name of the parameter is prefixed

    
answered by 26.09.2018 в 12:16