When should you use textual "or, and, not" over symbolic "||, &&, !" logical operators in JSP EL?
The textual versions may improve r开发者_StackOverfloweadability for non-programmers, but otherwise I can't imagine any differentiators.
From symbolic ones the &&
is syntactically invalid in XML (JSPX, Facelets), because it's a reserved XML character. You'd prefer the textual one in EL then. Since consistency is a good thing, you'd like to do the same for other operators.
By the way, the empty
operator doesn't have a direct symbolic counterpart since it not only tests on null
, but also on empty string (or collection size). Most close would be:
${var == null && fn:length(var) == 0}
The argument for empty
would then be that it is less typing and doesn't require JSTL functions.
精彩评论