EL syntax error on <c:if>

╄→гoц情女王★ 提交于 2019-12-02 16:04:38

问题


I am trying to create a condition for a link where if the length is not = 0 then show the description but I am getting a syntax error the code is:

<c:if test="#{fn:length(#{pqfn:format('ACTUAL_LINK')}) != 0}">
    <h:outputLink id="link1" value="#{pqfn:format('LINK_DESCRIPTION')}"/>
</c:if>

The error I am receiving is:

Caused by: org.apache.el.parser.ParseException: Encountered " <ILLEGAL_CHARACTER> "{ "" at line 1, column 14.
Was expecting one of:
    "." ...
    ")" ...
    "[" ...
    "," ...
    ">" ...
    "gt" ...
    "<" ...
    "lt" ...
    ">=" ...
    "ge" ...
    "<=" ...
    "le" ...
    "==" ...
    "eq" ...
    "!=" ...
    "ne" ...
    "&&" ...
    "and" ...
    "||" ...
    "or" ...
    "*" ...
    "+" ...
    "-" ...
    "/" ...
    "div" ...
    "%" ...
    "mod" ...

回答1:


You can not nest EL expressions as in #{... #{... ...} ...}. This is not making any sense. You should see an EL expression #{... ...} as one big scope where various EL scoped variables and EL functions can interact with each other.

The proper syntax is:

<c:if test="#{fn:length(pqfn:format('ACTUAL_LINK')) != 0}">

The particular exception you got is thrown because the EL parser unexpectedly encountered an { while one of the listed character sequences was expected at that point.




回答2:


You seem to be nesting one EL expression inside another ... that won't work:

#{fn:length(#{pqfn:format('ACTUAL_LINK')}) != 0}
            ^
      can't do this


来源:https://stackoverflow.com/questions/18962803/el-syntax-error-on-cif

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!