java 我如何隐藏空的 Velocity 变量名称?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How I hide empty Velocity variable names?
提问by Fernando Barrocal
I am using Struts + Velocity in a Java application, but after I submit a form, the confirmation page (Velocity template) shows the variable names instead an empty label, like the Age in following example:
我在 Java 应用程序中使用 Struts + Velocity,但在我提交表单后,确认页面(Velocity 模板)显示变量名称而不是空标签,如下例中的 Age:
Name: Fernando
Age: {person.age}
Sex: Male
姓名:费尔南多
年龄:{person.age}
性别:男
I would like to know how to hide it!
我想知道怎么隐藏!
回答by Jason Sparks
回答by Nathan Bubna
You will also need to be sure and use the proper syntax. Your example is missing the dollar before the variable. It should be $!{person.age}, not just {person.age}.
您还需要确保并使用正确的语法。您的示例在变量之前缺少美元。它应该是 $!{person.age},而不仅仅是 {person.age}。

