Reputation: 36021
Invoking a REST with a boolean parameter receives the value false
even though passing true
on the client side.
Client:
$http.post("http://localhost/getServers/?light=true")
Server:
@Path("/getServers")
@POST
@Produces({MediaType.APPLICATION_JSON})
public Response getServers(
@Context HttpServletRequest request,
@DefaultValue("true") @QueryParam("light") boolean light)
{
// light is false even though true was passed
...
}
Upvotes: 2
Views: 2781
Reputation: 36021
It seems that the slash (/
) before the question mark (?
) was the problem.
After removing the slash on the client side, everything worked fine.
This worked:
$http.post("http://localhost/getServers?light=true")
BUT, from reading on the web, a slash preceding a question mark is a legitimate syntax :(
Upvotes: 2