如何控制百里香中的href属性

Posted

技术标签:

【中文标题】如何控制百里香中的href属性【英文标题】:How to control the href attribute in thymeleaf 【发布时间】:2018-02-21 02:38:04 【问题描述】:

我是百里香的新手。

在 jsp 中问题很简单。但它在百里香中击败了我。

我想完成这个功能如下:

if (page.number<=1)
 html like this:
  <li class="q-pagination-disabled">Pre</li>
else
 <li><a href="/pages/page.number-1">Pre</a></li>

但是我不能用 th:if,th:href,th:remove 等等来完成它。 有人知道怎么做吗?

【问题讨论】:

【参考方案1】:

尝试以下方法,让我知道它是否适合您

<li th:if="$page.number le 1" class="q-pagination-disabled">Pre</li>
<li th:if="$page.number gt 1"><a th:href="@/pages/page(page=$page.number-1)">Pre</a></li>

【讨论】:

以上是关于如何控制百里香中的href属性的主要内容,如果未能解决你的问题,请参考以下文章