获取下一个数字

发布于 2025-01-25 02:18:03 字数 800 浏览 1 评论 0原文

我使用弹簧靴和百里叶奶酪,

我从模板中的数字开始

//想要显示startnubmer +1

//想要显示startnubmer +2

是否有一种方法可以用百里叶以

最终创建一个Java类

public class TLCounter {

    private int count;

    public TLCounter()
    {
        count = 0;
    }

    public TLCounter(int init)
    {
        count = init;
    }

    public int get()
    {
        return count;
    }

    public void clear()
    {
        count = 0;
    }

    public int incrementAndGet()
    {
        return ++count;
    }

    public String toString()
    {
        return ""+count;
    }

}

通过我的胸腺上的变量,然后调用方法

<th:block th:with="counterBullet = ${counter.incrementAndGet()}">
    <p th:text="${counterBullet}">1.</p>
</th:block>

I use spring boot and thymeleaf

I start with a number in a template

//want to display startNubmer +1

//want to display startNubmer +2

Is there a way to get that with thymeleaf

Finally create a java class

public class TLCounter {

    private int count;

    public TLCounter()
    {
        count = 0;
    }

    public TLCounter(int init)
    {
        count = init;
    }

    public int get()
    {
        return count;
    }

    public void clear()
    {
        count = 0;
    }

    public int incrementAndGet()
    {
        return ++count;
    }

    public String toString()
    {
        return ""+count;
    }

}

Pass a variable in my thymeleaf page, and call method

<th:block th:with="counterBullet = ${counter.incrementAndGet()}">
    <p th:text="${counterBullet}">1.</p>
</th:block>

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文