相关疑难解决方法(0)

Velocity nulls和空字符串

在速度我有一个变量,其值为null.在这种情况下,我不想显示任何内容.

目前模板引擎将""转换为null,所以我必须这样做.

#set ( $a = "")
#if ($a) 
   assert("never prints a neither gets here: " + $a)
#end
Run Code Online (Sandbox Code Playgroud)

有没有办法直接做到这一点?我希望能够做出类似的事情:

This is the variable $a. ## in case that $a is null i don't want 'dollar a' to be displayed
Run Code Online (Sandbox Code Playgroud)

java templates velocity

25
推荐指数
2
解决办法
4万
查看次数

标签 统计

java ×1

templates ×1

velocity ×1