sitemesh / sitemesh3

SiteMesh 3: Official repository
https://sitemesh.github.io/sitemesh-website/
Apache License 2.0
480 stars 168 forks source link

How to use in an embedded environment? #123

Closed Darkvater closed 1 year ago

Darkvater commented 5 years ago

I have been struggling for a few days now to get sitemesh3 working with embedded tomcat8 (in spring-boot) and I cannot get it working.

The only way it works is if I put the decorator file as a static resource such that the forwarded servlet can pick it up. This is not good for two reasons, you can access it directly (https://github.com/sitemesh/sitemesh3/issues/72) and this won't work if the decorator itself is dynamic, for example freemarker or velocity.

A working example of a dynamic decorator (freemarker for example) and a static decorator that is not a static resource to be served by the server would be much appreciated. The wiki is pretty much useless in this regard, only mentions everything is possible now but that's all.

For now I had to revert to sitemesh2 and do some creative package hiding to get stuff working. For anyone that is interested I had to package hide ConfigLoader and BaseFactory in which I had to make a few small changes to load the config/decorator as a class resource instead of a servlet resource.

codeconsole commented 1 year ago

Here is a working example with Freemarker, JSP and Thymeleaf

git clone https://github.com/sitemesh/sitemesh3
git checkout jakarta
../gradlew bootJar
java -jar build/libs/sitemesh-examples-springboot-4.0.0-SNAPSHOT.jar