-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
th:include/replace to allow server root relative URLs #554
Comments
@rattek including fragments is local and nothing to do with domains or URLs. You can think of this process like reading a local file from classpath. So it's not relevant to try including fragments via your app's web URL. Take a look here http://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#fragment-specification-syntax for some examples. |
As @destan correctly explained, template resolution is a configurable process independent of the URLs that your web server / web application is configured to respond to. Please have a look at the corresponding tutorial chapters on Template Layout to better understand this process. |
Thank you very much for the answers!! I was wondering that "UrlTemplateResolver" has been created especially for getting template that are not within the same application. To me it makes a lot of sense to share templates globally (for many applications). Do you know if there's a way to do so? Thanks again!! |
I have heard of people sharing templates across a network (I had one dev let me know that an in-development version of the layout dialect was really slow for them because they accessed templates across a network), so I think if your templates are served as HTML via any plain old HTTP web server, you can access it using that UrlTemplateResolver. |
Yes, this is exactly what I've done. UrlTemplateResolver worked as expected but it's not as portable as I wish ... It could be awesome to have a "DomainTemplateResolver" (or ServerRootTemplateResolver) which can take into account path starting with slash as I've described in by initial post. Thank you for taking my suggestion into consideration. |
@rattek |
The following to example refers to the same template hosted in my Spring project.
<th:block th:include="my/relative/uri" />
<th:block th:include="/my/relative/uri" />
However, I would like the first one to be relative to my project (http://mydomain.com/myproject/my/relative/uri) but the second to be relative to my server (http://mydomain.com/my/relative/uri).
In fact it's the same as for @{...} and @{~...}. This way, I could share template across my server.
Thank you to considerate!
The text was updated successfully, but these errors were encountered: