Reputation: 345
I am using Spring MVC, and I have a url request as: http://localhost:8080/address/getAddress/latitude=112.08&longitude=38.23
And my method is as:
@RequestMapping(value = "getAddress/latitude={latitude}&longitude={longitude}")
public @ResponseBody AddressResponse getAddress(@PathVariable double latitude, @PathVariable double longitude){
//my codes
}
But when I debug, the longitude is 38.0 instead of 38.23. Whatever longitude I entered, number after "." is always missing. I enter 38.28374, it comes out 38.0, I enter 29.87789, it comes out 29.0. Why this happens? And how can I fix it?
Upvotes: 2
Views: 339
Reputation: 2525
@RequestMapping(value = "getAddress/latitude={latitude:.+}&longitude={longitude:.+}")
will fix the issue. Normally nothing will be processed after the dot. This syntax will also accept values with dot.
Upvotes: 3