Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Using Spring's theme resolvers and themes with a Thymeleaf template [enhancement] #75

balteo opened this Issue · 6 comments

6 participants

balteo ashley7070 Pid Jan Boonen Emanuel Rabina Daniel Fernández

It would be a interesting enhancement to be able to use Spring's theme resolvers and themes in a Thymeleaf template.

Further information available on Thymeleaf's forum:


This is the only reason I am not using thymeleaf at the moment. We rely heavilly on spring:theme tag for multi branding.


Seems like a smashing idea.

Jan Boonen

This issue is already open for more than 6 months now. Any idea when it is planned to be implemented (I'd really love to use this feature in thymeleaf...). Perhaps someone can point in the right direction to start an implementation?

Emanuel Rabina

I haven't used Spring themes before, but from what I've read and looking at the source code of the JSP tag, I think what needs to happen is that we create a new utility object (eg: call it spring and it has a method theme()) that accepts a single parameter (the code value, which is a key into the theme's properties file), and returns the value from the properties file, writing it into the document structure.


<link rel="stylesheet" href="${#spring.theme('styleSheet')}" type="text/css"/>

Would become:

<link rel="stylesheet" href="themes/MyTheme.css" type="text/css"/>

Because the theme properties file had:

styleSheet = themes/MyTheme.css

All other Spring theme mechanisms (theme switching, interceptors, etc) should work without any change as they all go through Spring's DispatcherServlet.

@danielfernandez I can probably put together some proof-of-concept this week. I also think this change would be better suited to the thymeleaf-spring3 project, in which case a utility object called spring is probably a bad name. Maybe theme with the method name of code() instead?

Daniel Fernández

Looks like a very nice idea to me, Emanuel. Maybe #themes.code(...) or even #themes.theme(...) would be also nice possibilities...

Emanuel Rabina ultraq was assigned
Emanuel Rabina

Checked in code for a #themes.code(...) expression object as part of the thymeleaf-spring3 project, will be in version 2.0.17. Also did work on the Eclipse plugin to add support for this new object/method in version 2.0.1.

Emanuel Rabina ultraq closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.