posts - 91,  comments - 2,  views - 11万
  • js脚本中
var contextPath = "[[@{/}]]";

建议添加双引号,不加双引号也可以识别

  • <style>配置的样式中

方式一,建议,方便检查:

.custom {
    background: url('[[@{/path/xxx.png}]]');
    background-repeat: no-repeat;
}

方式二

.custom {
    background: url([[@{/]]/path/xxx.png});
    background-repeat: no-repeat;
}
  •  标签内嵌背景图片

修改前:

<div class="wave waveTop" style="background-image: url('/path/xxx.png')"></div>

修改后:

就像拼接字符串那样

<div class="wave waveTop" th:style="'background-image: url('+@{/path/xxx.png}+')'"></div>

说明:属性添加"th:"后,页面打开时,会被动态计算处理(实际页面显示的源码结果中并不包含th:开头的属性)

1、这个由springboot依赖的spring-boot-starter-thymeleaf实现

2、内置方法参考,另外一个随笔:springboot整合thymeleaf, html使用预置方法

https://www.cnblogs.com/leonlipfsj/p/18181213

 

 

,

posted on   le.li  阅读(188)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示