似乎没有任何具体的答案,尽管我更倾向于说这是不可能的。
但是,是否可以在外部CSS文件中使用Thmymeleaf表达式?例如,如果我有 main.css 并且它包含:
body {
font-size: [[${fooBean.isLarge ? '22px;' : '16px;' }]];
}
.header {
margin-top:
background: url{[[${fooBean.isMain ? '/img/blue.jpg' : '/img/red.jpg' }]]}
no-repeat center center fixed;
}
这是否可以使用Thymeleaf?
答案 0 :(得分:1)
Thymeleaf 3 introduced new template modes。其中一个是CSS,you can see an example of one here。您必须设置所有弹簧材料/控制器,但您应该能够像平常一样使用它们(将fooBean添加到模型中)。