Fix ResourceUrlEncodingFilter with context mapping

Prior to this change, the ResourceUrlEncodingFilter would work well when
the application is mapped to "/". But when mapped to a non-empty servlet
context, this filter would not properly encode URLs and apply
ResourceResolver URL resolution for resources.

This commit makes sure that the lookup path is properly resolved in the
request URI, taking into account the servlet context.

Issue: SPR-12459
This commit is contained in:
Brian Clozel
2014-11-26 14:49:43 +01:00
parent feb91e8366
commit b3bfa95e2b
2 changed files with 102 additions and 1 deletions

View File

@@ -88,7 +88,7 @@ public class ResourceUrlEncodingFilter extends OncePerRequestFilter {
if (this.indexLookupPath == null) {
String requestUri = urlProvider.getPathHelper().getRequestUri(this.request);
String lookupPath = urlProvider.getPathHelper().getLookupPathForRequest(this.request);
this.indexLookupPath = requestUri.indexOf(lookupPath);
this.indexLookupPath = requestUri.lastIndexOf(lookupPath);
}
}
}