Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
ServletContextResourcePatternResolver fails to resolve resources when an app is using a foo#bar.war filename [SPR-10471] #15104
The issue can be reproduced with WAR files using the following naming scheme:
The foo#bar.war name is required when you want to achieve a deep context path value like /foo/bar.
The ServletContextResourcePatternResolver and the UrlResource implementation which is used internally do not provide any handling for special characters like #. This leads to a MalformedURLException.
The private doRetrieveMatchingJarEntries method of the ServletContextResourcePatternResolver cannot be overridden and the only workaround at the moment is to duplicate the whole class logic in a custom implementation. A simple encoding of the special character fixes the issue.