为什么要为HREF百里香毛?

发布于 2025-01-24 12:28:12 字数 305 浏览 1 评论 0原文

我正在部署一个模板,该模板包括弹簧靴,胸腺和引导程序。

为什么模板需要胸腺膜组件?通常,通过从控制器中接收数据,胸腺用于填充索引。但是在这种情况下,胸腺仅在“ href”的前面使用,例如:

[...] th:rel=“stylesheet“ th:href=“@{assets/datatable/datatables.css}"/>

为什么在这种情况下我需要胸腺?如果没有th -prefixes,是否可以在普通HTML中创建此类引用?真的有必要在这里使用胸腺吗?如果是:为什么?

I am deploying a template that comprises Spring Boot, Thymeleaf and Bootstrap.

Why does the template need the Thymeleaf component? Normally, Thymeleaf is used to populate the index.html-datatable by receiving data from the controller. But in this case, Thymeleaf is only used in front of the „href“, e.g. like:

[...] th:rel=“stylesheet“ th:href=“@{assets/datatable/datatables.css}"/>

Why do I need Thymeleaf in this case? Isn't it possible to create such references in normal HTML just without the th-prefixes? Is it really necessary to use Thymeleaf here? If yes: Why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情场扛把子 2025-01-31 12:28:12

是的,可以在没有th:href的情况下创建链接。在这种情况下,看起来没有任何理由使用它(因为它是相对链接)。

话虽如此,如果链接是上下文相对的(以slash @{/assets/dataTable/datatables.css}),使用th:href让您部署对不同上下文的应用而无需更改链接。如果您不使用th:href,则必须更改代码才能部署到不同的上下文。例如

href="/my-application/assets/datatable/datatables.css"

,如果您决定将应用程序上下文更改为/my-Online-portal/之类的内容,则将无法使用。

此:th:href =“@{/Assets/datatable/datatables.css}”在两种情况下都可以使用,并产生/my-application/assets/datatable/datatable/datatables.css.css 或/my-online-portal/assets/datatable/datatables.css取决于部署到的上下文。

Yes, it's possible to create links without th:href. In this case, doesn't look like there is any reason to use it (since it's a relative link).

That being said, if the link was context relative (starting with a slash @{/assets/datatable/datatables.css}), using th:href would let you deploy the application to different contexts without having to change the link. If you didn't use a th:href you would have to change the code to deploy to a differnt context. E.g.

href="/my-application/assets/datatable/datatables.css"

wouldn't work if you decided to change the application context to something like /my-online-portal/.

This: th:href="@{/assets/datatable/datatables.css}" would work in both cases and produce /my-application/assets/datatable/datatables.css or /my-online-portal/assets/datatable/datatables.css depending on the context it's deployed to.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文