• 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 2024-05-08 23:55  le.li  阅读(283)  评论(0)    收藏  举报