Velocity :在 apache velocity 中关闭严格模式

Velocity : Turning off Strict mode in apache velocity

如何在 apache velocity 中关闭严格模式? Velocity 将为未在上下文中定义的引用抛出 MethodInvocationException。在那种情况下,我需要它不渲染任何内容。

如何启用非严格模式?

尝试了 $!name,但如果未在上下文中定义,这也会引发错误。

你应该试试

runtime.references.strict = false

有关更多信息,请查看下方 link: http://velocity.apache.org/engine/1.7/developer-guide.html