后台封装了一个对象 放在model里:

model.addAttribute("notice", notice);

notice是个对象

 

然后前台如果没有公告的话,希望显示暂无公告:

【JSTL】没有else的解决方法

 

前台<c:if>没有else的逻辑,怎么解决?

 

解决方案:

 <div class="panel-body">
                   <c:choose>

                       <c:when test="${notice != null}">   
                            <h2 style = "text-align: center;">${notice.noticeName}</h2>
                           <h4 style = "text-align: center;">公布人:${notice.noticeCre}</h4>
                           <h4 style = "text-align: center;">公布日期:${noticeTime}</h4>
                           <br>
                           <div style = "text-align: center;">
                               ${notice.noticeContent}
                           </div>
                       </c:when>
                       <c:otherwise>  
                           <h2 style = "text-align: center;">暂无公告</h2>
                       </c:otherwise>
  
                </c:choose>
                   
          </div>

如此,有公告的时候,就显示,没有就是暂无公告:

【JSTL】没有else的解决方法

 

相关文章:

  • 2021-09-02
  • 2021-11-29
  • 2021-04-02
  • 2021-04-06
  • 2021-09-09
  • 2022-02-15
  • 2022-12-23
  • 2021-06-25
猜你喜欢
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2022-01-10
相关资源
相似解决方案