在Spring MVC中有条件地呈现HTML [英] Render HTML conditionally in Spring MVC

查看:148
本文介绍了在Spring MVC中有条件地呈现HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何标记可以有条件地呈现HTML块。例如:Struts有:

Is there any tag which lets to render the HTML blocks conditionally. For e.g.: Struts has:

<logic:present name="someForm" property="someProperty">
    //Code block
</logic:present>

例如:JSF有:

<h:panelGrid rendered="#{not empty someList}">
    //Some code block
</h:panelGrid>

在春季MVC中有类似的东西吗?

Is there anything like that in spring MVC?

推荐答案

简单的旧JSTL给你救援!

Plain old JSTL to your rescue!

Spring MVC的优点在于它不会像其他框架那样增加大量的冗余标记库。您现在可以依赖JSTL进行此类检查,这些检查现在是JSP规范的一部分。

The beauty of Spring MVC is that it doesn't add tons of redundant tag libraries unlike other frameworks. You can always rely on JSTL for such checks which is part of the JSP spec now.

<c:if test="${not empty someList}">

</c:if>

这篇关于在Spring MVC中有条件地呈现HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆