EL syntax error on

2019-03-04 10:51发布

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" ...

标签: jsf el
2条回答
Fickle 薄情
2楼-- · 2019-03-04 10:53

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.

查看更多
何必那么认真
3楼-- · 2019-03-04 11:07

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
查看更多
登录 后发表回答