I'm working on a Spring 2.5 project where four different webapps have duplicate JSPs (they were all derivations of the same webapp). I want to introduce Freemarker so I can externalize and reuse these templates across all the webapps. However, I want to approach this iteratively since it's going to be a big project, so I need JSP and Freemarker to live in harmony for awhile.
I know Spring allows chaining multiple ViewResolvers, but JSP's InternalResourceViewResolver and Freemarker's FreeMarkerViewResolver both state that they need to be last in the chain. I've tried to chain them anyways and specify an order priority, but no luck.
Freemarker seems to support JSPs to some degree, though I don't really see how I could use that in a gradual migration (http://freemarker.sourceforge.net/docs/pgui_misc_servlet.html).
Does anyone have any ideas?
FreeMarker has all the essential features to generate HTML for most of the cases, and it is easier to learn. So it is not a bad idea if you want to use it. However, Thymeleaf is the way to go if you want to add custom functionality to your templates.
FreeMarker is a server-side Java template engine for both web and standalone environments. Templates are written in the FreeMarker Template Language (FTL), which is a simple, specialized language. Note: Spring Boot recently changed the default extension from . ftl to . ftlh.
Can I allow users to upload templates and what are the security implications? In general you shouldn't allow that, unless those users are system administrators or other trusted personnel. Consider templates as part of the source code just like *.
In Spring 2.5 you'll probably have to use a BeanNameResolver since you can't have two URL resolvers, see this thread. This got much easier in 3.0 where you can order resolvers.
References
NixMash Post: The Move from Velocity to FreeMarker with Spring Boot
A Review of Java Template Engines - DZone Web Dev
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With