0

I want to restrict a @PathVariable mapping to only accept latitude/longitude valid values. For instance, the regexp for latitude is ^-?([1-8]?[1-9]|[1-9]0)\.{1}\d{1,6}. Hence, Spring sees {1} and {1,6} as path variables. Here is the code snippet:

@RequestMapping(value = "@{userLatitude:^-?([1-8]?[1-9]|[1-9]0)\\.{1}\\d{1,6}},{userLongitude},{radiusOfSearchInKm}", method = RequestMethod.GET)
    @ResponseBody
    public List<DTO> nearbyShops(@PathVariable double userLatitude, @PathVariable double userLongitude, @PathVariable double radiusOfSearchInKm) {
        return mappingFacade.mapShopsListToShopDTOsList(getNearbyShops(userLatitude, userLongitude, radiusOfSearchInKm));
    }

I'm looking for a way to escape the curly braces in the regexp so it's seen as a whole regexp. How to do that!

Anouar Bellakha
  • 139
  • 1
  • 5
  • 14

0 Answers0