Open odrotbohm opened 3 years ago
I was looking into preparing a pull request but I am a bit lost in the arrangement. It looks like the type to fix is AbstractConfigurableTemplateResolver
living in the thymeleaf
repository. The tests however live in thyme leaf-tests
so that it apparently needs two distinct PRs that are somehow related but have to be independent at the same time. In the tests repo, the last change on the master branch is dated back to 2015. That said, it looks like the repository has individual branches for different Spring versions but none for the current 5.3 version.
I am happy to take a little guidance on how to proceed, where to add the necessary changes but essentially what I'd suggest is a .replaceAll("//", "/")
on what's computed in AbstractConfigurableTemplateResolver.computeResourceName(…)
.
Assume a template
sample.html
present insrc/main/resources/templates
of a Spring Boot application, Boot configuring thetemplates
folder to be the root folder for view resolution and a Spring MVC controller returning/sample
as view name.In that case, Thymeleaf resolves the template if the application is run exploded (in the IDE or via the Spring Boot build plugin) but fails to resolve the template when it's run in packaged mode. This seems to be due to a double slash ending up in the resource name to be looked up (
templates//sample.html
) and the different classloader in place not cleaning that up.I know that returning
sample
would be the correct thing to do but I've seen beginners using/sample
without thinking about it as it works just fine in their IDE.Does it make sense to wipe double slashes from the resource name to look up before trying to do so?