Description
I'm using spring mvc 4 with thymeleaf,
i can configure thymeleaf using RouterModelAttribute in this way i have access in my view to the router with default name 'route'
My routes.conf content:
-
/test/1 testController.foo
When i do ${route.reverse('testController.foo')} it give me the value of '/test/1/test/1' which is wrong url, i expect to /test/1 which is the value mapped to testController.foo.
I have looked to the code in the reverse method:
String path = route.path;
if( currentRequest != null) {
if(!currentRequest.servletPath.isEmpty() && !currentRequest.servletPath.equals("/")) {
String servletPath = currentRequest.servletPath;
path = (servletPath.startsWith("/") ? servletPath : "/" + servletPath) + path;
}
if(!currentRequest.contextPath.isEmpty() && !currentRequest.contextPath.equals("/")) {
String contextPath = currentRequest.contextPath;
path = (contextPath.startsWith("/") ? contextPath : "/" + contextPath) + path;
}
}
** by removing this code the reverse method works as i should expect:
if(!currentRequest.servletPath.isEmpty() && !currentRequest.servletPath.equals("/")) {
String servletPath = currentRequest.servletPath;
path = (servletPath.startsWith("/") ? servletPath : "/" + servletPath) + path;
}
Could you confirm this issue?