【问题标题】:Check if property exist (Lexical error _ after .)检查属性是否存在(词法错误 _ after .)
【发布时间】:2019-08-15 13:26:25
【问题描述】:

我有这个导致词法错误的 sn-p

#if( $context.args.input._publics )
  $util.unauthorized()
#end

错误信息是

Lexical error,   Encountered: \"_\" (95), after : \".\"

如何检查_publics 是否存在于$context.args.input?我不能改名字_publics

【问题讨论】:

标签: velocity template-engine vtl


【解决方案1】:

这是一个Velocity 1.7 bug,已在 2.0 中修复。

要解决它,您可以这样做:

#if( $context.args.input.containsKey('_publics') )
    $util.unauthorized()
#end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-25
    • 2020-06-09
    • 2011-02-01
    相关资源
    最近更新 更多