It's hard to see how StringTemplate integrates easily (or not) with popular Java web MVC frameworks.
Which Java MVC frameworks integrate easily with StringTemplate?
A good answer:
- mentions one solution to integrate with a framework,
- includes a link to something useful and applicable, like:
- a tutorial,
- or documentation,
- or a reference to source code:
- free,
- and open source or public domain.
Readers/Voters, please vote for a solution if you know it's true and great.
In the scope of this question, I am not interested in any other templating engine than StringTemplate.
I've gotten StringTemplate to work with Spring. Basically, all it took was a custom view.
But first, a disclaimer: This is an experimental hack. I've never used this in production code, and it could use some improvement before that happens. I think it is adequate to answer your question about how easily StringTemplate integrates with a Web MVC framework, however.
Reference: Spring Web MVC documentation
StringTemplateView.java:
And an example view resolver definition:
A quick search led me to this demonstration of using StringTemplate for a Spring view.
A certain Harry Karamidas shared, in December 2008, a Struts adapter on ST's official site. Direct link to the zip file.
There is a not bad implementation of StringTemplate as a view for Spring MVC that also supports SiteMesh integration.
https://github.com/tomcz/spring-stringtemplate/
There is an example implementation of a webapp using ST as the view technology within this project (including the sitemesh integration). It is not worth repeating it here, so the pointer to it directly is:
https://github.com/tomcz/spring-stringtemplate/tree/master/src/test/webapp/WEB-INF
The author has also provided support for encoding/escaping output for XSS prevention. This support exists for HTML, CSS, XML, JS and URLs.
If you're a Maven user, the project is available on central
The open source Java WEB framework JPublish, works very well with ST. By following the link above, you'll find there the following:
Have fun,