How do I check two or more conditions in one ?

后端 未结 4 1352
说谎
说谎 2020-12-02 12:36

How do I check two conditions in one ? I tried this, but it raises an error:



        
相关标签:
4条回答
  • 2020-12-02 13:21

    If you are using JSP 2.0 and above It will come with the EL support: so that you can write in plain english and use and with empty operators to write your test:

    <c:if test="${(empty object_1.attribute_A) and (empty object_2.attribute_B)}">
    
    0 讨论(0)
  • 2020-12-02 13:24

    Recommendation:

    when you have more than one condition with and and or is better separate with () to avoid verification problems

    <c:if test="${(not validID) and (addressIso == 'US' or addressIso == 'BR')}">
    
    0 讨论(0)
  • 2020-12-02 13:29

    This look like a duplicate of JSTL conditional check.

    The error is having the && outside the expression. Instead use

    <c:if test="${ISAJAX == 0 && ISDATE == 0}">
    
    0 讨论(0)
  • 2020-12-02 13:37

    Just in case somebody needs to check the condition from session.Usage of or

    <c:if test="${sessionScope['roleid'] == 1 || sessionScope['roleid'] == 4}">
    
    0 讨论(0)
提交回复
热议问题