Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 直到一个数字_Java_Spring Boot_Thymeleaf - Fatal编程技术网

Java 直到一个数字

Java 直到一个数字,java,spring-boot,thymeleaf,Java,Spring Boot,Thymeleaf,我使用Thymeleaf进行搜索并从服务器获得响应。这包含了以下结果的数量: ${response.count} 我想进行这样的迭代: for (int i = 1; i <= response.count; i++) { if (response.page == i) { <button class="active">Dummy</button> } else { <button>Dummy</b

我使用Thymeleaf进行搜索并从服务器获得响应。这包含了以下结果的数量:

${response.count}
我想进行这样的迭代:

for (int i = 1; i <= response.count; i++) {
    if (response.page == i) {
        <button class="active">Dummy</button>
    } else {
        <button>Dummy</button>
    }
}
${#numbers.sequence(0, response.count)}
但是没有起作用

编辑:我试过了,但也没用:

<button th:each="i: ${#numbers.sequence(0, response.count - 1)}" th:class="${i == response.page} ?: active">Dummy</button>
Dummy
这对我很有用:

<th:block th:each="i: ${#numbers.sequence(0, response.count - 1)}">
    <button th:if="${response.page == i}" class="active">Dummy</button>
    <button th:unless="${response.page == i}">Dummy</button>
</th:block>

笨蛋
笨蛋

这就是你所想的吗?试试这个假人,我不认为你可以在这个例子中使用“?:”但是“?”很好用。我接受了你的答案,但是按照你的评论方式实现了,谢谢。