Spring MVC "duplicates" parts of the URL

I guess it's related to default view name resolution.

If you want a value returned by your handler method to be encoded as response body (in JSON, XML, etc), you need to annoate the method with @ResponseBody, or annotate the whole controller with @RestController (in Spring 4.x).

Otherwise, Spring tries to render a view with your return as model attribute. And since you didn't provide a name of a view to render, Spring tries to deduce it from request URL.


In addition to @axtvat, pay attention to the differences between @Cotroller and @RestController, @RestController fixed the issue for me. https://dzone.com/articles/spring-framework-restcontroller-vs-controller