jstl 可以检查属性是否已添加到模型中吗?
是否可以检查属性是否已添加到模型中?
//in the controller teh variable is not always added
//
model.addAttribute("variable", myVariable);
在 jsp 中是这样的
<c:choose>
<c:when test="${variable is present}">
Not present
</c:when>
<c:otherwise>
Present
</c:otherwise>
</c:choose>
谢谢
Is it possible to check if an attribute has been added to the model?
//in the controller teh variable is not always added
//
model.addAttribute("variable", myVariable);
and in the jsp something like this
<c:choose>
<c:when test="${variable is present}">
Not present
</c:when>
<c:otherwise>
Present
</c:otherwise>
</c:choose>
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JSTL/EL 无法检查属性是否已添加到模型中。为此,您需要自己实现一个观察者/可观察对象。
然而,EL 可以检查 bean 属性或映射值是否不为 null 或为空。
另请参阅:
JSTL/EL cannot check if an attribute has been added to the model. For that you need to implement an observer/observable yourself.
EL can however check if a bean property or a map value is not null or empty.
See also:
您可以检查属性是否为空
You can check if the attribute is empty