【问题标题】:What is @{..} expression in ThymeleafThymeleaf 中的 @{..} 表达式是什么
【发布时间】:2019-03-10 06:37:45
【问题描述】:
<html>
<head>
<title>Reading List</title>
<link rel="stylesheet" th:href="@{/style.css}"></link>
</head>

在我开发一个 Spring Boot 项目时,根据一些要求,我想通过使用 thymeleaf 添加/加载一些静态资源内容。在加载/引用 css 文件时,我使用的是 thymeleaf 标签。

th:href="@{/style.css}

谁能解释一下我们为什么使用表达式'@'?

【问题讨论】:

标签: spring-boot thymeleaf


【解决方案1】:

这是link expressions

链接表达式,一种 Thymeleaf 标准表达式:@{...}

只需在链接前添加@,以便 Thymeleaf 将表达式识别为链接

具体来说,您使用的是上下文相关的 URL

上下文相关的 URL 以 / 开头

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-17
    • 2019-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-26
    相关资源
    最近更新 更多