标签: velocity-tools

无法在 Velocity 模板中设置 Null

我试图在 Velocity 中将变量设置为 null。我在尝试:

#set ($acessSpeed = null)
Run Code Online (Sandbox Code Playgroud)

我正在阅读速度空支持维基。它说我们可以通过这种方式将值设置为 null。 https://wiki.apache.org/velocity/VelocityNullSupport

但是当我尝试它时,我收到一条错误消息“在......遇到“null””

我遇到的问题是我有一个巨大的模板,其中包含多个 if 块,如果满足条件,则执行这些块。因此,在每个 if 块的末尾,我需要将 accessSpeed 的值设置为 null。

#if (some condition)
     access speed value set here.
.
.
.
#end
// I need to set the access speed value to null here.
#if (some other condition)
    access speed value to be set to something again.
.
.
.
#end
Run Code Online (Sandbox Code Playgroud)

我可以为每个 if 块使用不同的变量,但我想知道是否有更简单的方法来做到这一点。

任何的意见都将会有帮助。

java velocity velocity-tools

3
推荐指数
1
解决办法
5096
查看次数

标签 统计

java ×1

velocity ×1

velocity-tools ×1