Sunday, 25 August 2013

Dispaly Spring MVC model attributes in thymeleaf template

Dispaly Spring MVC model attributes in thymeleaf template

I am developing full Spring application with Spring MVC and Thymeleaf in
view layer. In past I've worked with JSPs and Spring MVC in view layer,
but those are now dinosaurs I guess.
So my problem is that with JSPs I could very easily display model
attributes in view by adding value in model.addAttribute in controller and
displaying the same in JSP anywhere with placeholder evaluating to
springex ${value}. So if I want to place a title in page I can write
${appName}. This is one of the places where I can put any springex.
I am having hard time to figure out how to do this with Thymeleaf as it
uses attribute based parsers. So anywhere on page if thymeleaf prefix is
not included it won't process spring expression. It's very hard to work
with limited set of tag libraries. I've heard of custom attributes for
thymeleaf but I guess there should be a better way to do this.

No comments:

Post a Comment