Is there a way to get the whole query string without it being parsed? As in:
http://localhost:8080/spring-rest/ex/bars?id=100,150&name=abc,efg
I want to get everything following the ? as one string. Yes I will parse it later, but this allows my controller and all follow-on code to be more generic.
So far I've tried using @PathParam, @RequestParam as well as @Context UriInfo with the results following. But I can't seem to get the whole string. This is what I want:
id=100,150&name=abc,efg
Using curl @PathParam using
http://localhost:8080/spring-rest/ex/bars/id=100,150&name=abc,efg
produces id=100,150
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/spring-rest/ex/qstring/{qString}")
public String getStuffAsParam ( @PathParam("qstring") String qString) {
...
}
@RequestParam using
http://localhost:8080/spring-rest/ex/bars?id=100,150&name=abc,efg
gives name not recognized.
http://localhost:8080/spring-rest/ex/bars?id=100,150;name=abc,efg
produces exception.
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/spring-rest/ex/qstring")
public String getStuffAsMapping (@RequestParam (value ="qstring", required = false) String[] qString) {
...
}
EDIT - THE APPROACH BELOW IS WHAT I'D LIKE TO FOCUS ON.
This works almost. It doesn't give me the full query string in the MultivaluedMap. It is only giving me the first string up to the &. I've tried using other characters as the delimiter and still doesn't work. I need to get this string in its undecoded state.
@Context with UriInfo using
http://localhost:8080/spring-rest/ex/bars?id=100,150&name=abc,efg
gives value for queryParams id=[100,150]. Again the name= part was truncated.
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/spring-rest/ex/qstring")
public String getStuffAsMapping (@Context UriInfo query) {
MultivaluedMap<String, String> queryParams = query.getQueryParameters();
...
}
I'm thinking the query string is being decoded which I don't really want. How do I get the whole string?
Any help is greatly appreciated.