【问题标题】:How can I test two attributes in jsp using c:if tag?如何使用 c:if 标记在 jsp 中测试两个属性?
【发布时间】:2017-02-25 00:01:13
【问题描述】:

我想使用 jstl 标签 c:if 检查从服务器发送的两个属性是否为空或不在 jsp 中。例如,我可以使用检查错误是否为空:<c:if test="${not empty error}"></c:if> 像这样,我想检查两个对象错误并立即注销以创建一个 div,如果它们中的任何一个为空。我该怎么做?

【问题讨论】:

    标签: jsp spring-mvc jstl


    【解决方案1】:

    使用 AND 运算符 && 或 OR 运算符 ||

    <c:if test="${not empty first && not empty second}"></c:if>
    <c:if test="${not empty first || not empty second}"></c:if>
    

    如果您希望它们为空

    <c:if test="${empty first && empty second}"></c:if>
    <c:if test="${empty first || empty second}"></c:if>
    

    【讨论】:

      猜你喜欢
      • 2010-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-02
      • 2010-10-20
      • 1970-01-01
      • 2012-06-26
      • 1970-01-01
      相关资源
      最近更新 更多