mercredi 17 juin 2015

How to pass two query parameters in URL

@Stateless
@Path("projection")
public class ProjectionManager {

@Inject
private ProjectionDAO projectionDAO;

@Inject
private UserContext userContext;

@GET
@Path("{projectionId}")
@Produces("application/json")
public String places(@PathParam("projectionId") String projectionId) {
    return projectionDAO.findById(Long.parseLong(projectionId)).getPlaces().toString();
}}

In this example the url for this service should be /projection/projectionId, but how i can have access to a service with two or more query parametar in this code :

@PUT
@Path("/buy")
public Response buyTicket(@QueryParam("projectionId") String projectionId, @QueryParam("place") String place){
    Projection projection = projectionDAO.findById(Long.parseLong(projectionId));
    if(projection != null){
        projectionDAO.buyTicket(projection, userContext.getCurrentUser(), Integer.parseInt(place));
    }

    return Response.noContent().build();
}

Aucun commentaire:

Enregistrer un commentaire