2

I am working on a web project and using Spring MVC 3.1.1. Spring MVC is used to serve REST services (using URL annotations)

Regarding to my problem:

Let's say my url path for a service is as;

http://localhost:8080/MyAppName/services/meteo/queryWeatherData/lon/39.1123/lat/39.3123

And my controller method is as;

@RequestMapping(method = RequestMethod.GET, value = {"/queryWeatherData/lon/{lon}/lat/{lat}"})
    public void queryWeatherData(
            final @PathVariable("lon") float lon,
            final @PathVariable("lat") float lat,
            final HttpServletResponse response, final HttpServletRequest request) {
//
// DO STUFF and prepare response
//
}

I see that the second parameter (lat) is truncated after "." so I see that the value is 39.0 in server side.

I tried declaring a DefaultAnnotationHandlerMapping bean in my app-context.xml and set its useDefaultSuffixPattern to false but it did not work.

How can I solve this issue?

3
  • Try putting a slash at the end i.e. http://localhost:8080/MyAppName/services/meteo/queryWeatherData/lon/39.1123/lat/39.3123/. If that changes it it maybe that it looks as .3123 as file extension.
    – ced-b
    Sep 24, 2013 at 13:39
  • Possible duplicate of stackoverflow.com/questions/3526523/…
    – M. Abbas
    Sep 24, 2013 at 13:46
  • I am aware of the possible duplicate issue but the instructions on that one did not work for me
    – iso_9001_
    Sep 24, 2013 at 13:53

1 Answer 1

2

Declaring the DefaultAnnotationHandlerMapping bean with useDefaultSuffixPattern=false is the right approach, but make sure you also comment out:

<mvc:annotation-driven />

See: How to change Spring MVC's behavior in handling url 'dot' character

1
  • I tried declaring the DefaultAnnotationHandlerMapping bean with useDefaultSuffixPattern=false but I didn't comment out <mvc:annotation-driven /> and that was the case. Thank you very much
    – iso_9001_
    Sep 24, 2013 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.