首页 > Web开发 > 详细

【JSTL】<c:if test=“”>没有else的解决方法

时间:2017-04-06 18:57:56      阅读:261      评论:0      收藏:0      [点我收藏+]

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

model.addAttribute("notice", notice);

notice是个对象

 

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

技术分享

 

前台<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】<c:if test=“”>没有else的解决方法

原文:http://www.cnblogs.com/sxdcgaq8080/p/6674612.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!