404 Error with Java EE Web service GET request with decimal point in parameter value
I've created a Java stateless session bean to provide RESTful services to clients, and I get a 404 Not Found erorr when I pass in a parameter with a decimal point (specifically a longitude, e.g. 150.318232). The service works fine if the value passed in is an integer.
Below is a snippet of the code from the relevant method - it was o开发者_StackOverflow中文版riginally generated using the Netbeans wizards.
@GET
@Produces({"application/json"}) //, "application/xml"
public MessagesConverter get(@QueryParam("start")
@DefaultValue("0")
int start,
......
@QueryParam("longitude")
@DefaultValue("-123456789")
long searchPointLongitude,
......
I've tried encoding the URL such that the periods / dots are submitted as hex codes, but this still doesn't seem to rectify the problem.
Any help would be appreciated.
Cheers,
Jin
Well in your example your argument is a long - which I assume is what you are trying to use for that query param. But the param you pass in is a double or float, not a long.
Unlikely, but make sure your decimal isn't rendering to a string using a locale that the endpoint doesn't like. I've written code in my native locale which rendered decimals using periods (.), only to have that code execute later in locales which render decimals using commas (,), which really upset the endpoint service, even when properly URL-encoded.
精彩评论