5 ms·
What templating language did you use with Spring MVC?
by jsight 10y ago
What templating language did you use with Spring MVC?
- spapas82 10y agothymeleaf (http://www.thymeleaf.org/ http://www.thymeleaf.org/) - it is supported directly by spring boot (spring-boot-starter-thymeleaf dependecy). Also, using thymeleaf-extras-springsecurity4 you can integrate spring security tags with thymeleaf so that you can conditionally render things depending on the current user/authority into your templates!
- Deinumite 10y agoI've been looking at http://www.mitchellbosecke.com/pebble/home http://www.mitchellbosecke.com/pebble/home but I have not yet had a chance to use it.
- spapas82 10y agoHmmm seems nice and has a djangonic syntax! However I'm not really sure how easy would be to integrate with spring boot (and spring security)...
- Deinumite 10y agoI'm not sure about Spring Security but as for Spring Boot itself http://www.mitchellbosecke.com/pebble/documentation/guide/spring-integration http://www.mitchellbosecke.com/pebble/documentation/guide/sp...
- manyxcxi 10y agoI've been using Thymeleaf with Spring for a while and almost always exclusively use it with Spring Boot because it's pretty much right out of the box ready to go. I stumbled on it a long time ago because I had the problem of Java devs needing to integrate templates built by front end devs and all the churn that goes along with it. It uses custom tag attributes like th:href to swap the computed value in on template render so you can have a completely perfect looking HTML/CSS/JS template with the placeholder values without having to convert back and forth. It's just HTML with extra attributes that get ignored when not run through the rendering process. You can use Spring Expressions, forms, and security with pretty much no configuration, it works awesome. It supports partials and layouts and all the good stuff you'd want for reuse and it took me about 10 minutes to create a custom dialect for it that lets me use Thymeleaf and Vue.js together very nicely. I can't recommend Thymeleaf enough.
- kentosi 10y agoOne issue is if you're using Angular. Your html document needs to be xhtml compatible, meaning that an expression like this: <div ng-if="this() && that()" ... Needs to become: <div ng-if="this() && that()" ... If this doesn't bother you (along with > for <, etc) then go ahead.
- manyxcxi 10y agoIt doesn't have to if you write your own dialect for Thymeleaf. You can alter the flow of the output manipulation and validation- it's out of the box that it chokes on the 'weird' stuff being shoved into attribute tags nowadays for JS templates. If you want the unescaped output there are lots of things you can do. I did something similar for Vue.js in about twenty minutes and a few lines of code.
- tootie 10y agoFreemarker. Why doesn't every template language have macros?