lundi 6 avril 2015

jersey @PathParam: how to pass a variable which contains more than one slashes


Vote count:

0





package com.java4s;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
@Path("/customers")
public class RestServicePathParamJava4s {
@GET
@Path("{name}/{country}")
@Produces("text/html")
public Response getResultByPassingValue(
@PathParam("name") String name,
@PathParam("country") String country) {

String output = "Customer name - "+name+", Country - "+country+"";
return Response.status(200).entity(output).build();

}
}


In web.xml i have specified URL pattern as /rest/* and in RestServicePathParamJava4s.java we specified class level @path as /customers and method level @path as {name}/{country} So the final URL should be http://localhost:2013/RestPathParamAnnotationExample/rest/customers/Java4/USA it will display Customer name - Java4, Country - USA. if i give the 2 input given below it is showing an error. how to slve this. http://localhost:2013/RestPathParamAnnotationExample/rest/customers/Java4:kum77./@.com/USA, here Java4:kum77./@.com this one is one string and it contains forward slash. how to accept this by using pathparam. or wheter i need to use multivaluedmap. if somebody knows this plz help me. if anyone knows what is multivaluedmap, give me a simple example?



asked 45 secs ago







jersey @PathParam: how to pass a variable which contains more than one slashes

Aucun commentaire:

Enregistrer un commentaire