Using Spring's theme resolvers and themes with a Thymeleaf template

*爱你&永不变心* 提交于 2020-01-04 04:47:07

问题


I would like to use Spring theme resolvers' feature (see: here) in my Thymeleaf template.

What is the Thymeleaf's equivalent to the spring:theme JSP tag?

See JSP code sample below:

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html>
   <head>
      <link rel="stylesheet" href="<spring:theme code='styleSheet'/>" type="text/css"/>
   </head>
   <body style="background=<spring:theme code='background'/>">
      ...
   </body>
</html>

回答1:


I don't think this was the case at the time that you asked your question, but the current version of thymeleaf-spring3 (2.0.18 as of this writing) has as part of the SpringStandard dialect a themes function, which can be used like this:

<body th:style="'background-color: ' + ${#themes.code('backgroundColor')}">


来源:https://stackoverflow.com/questions/12262530/using-springs-theme-resolvers-and-themes-with-a-thymeleaf-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!