如何检查JSTL对象是String还是Collection? [英] How to check in JSTL whether object is String or Collection?
本文介绍了如何检查JSTL对象是String还是Collection?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用JSTL并且想要检查对象是字符串还是集合。
I'm using JSTL and want to check whether an object is a String or a Collection.
fn:length返回两种类型的结果(stringsize或number of集合中的元素。)
fn:length returns results on both types (stringsize or number of elements in the collection).
<c:if test="${fn:length(item)>1}">
<c:out value="${fn:length(item)} " />
</c:if>
我如何确定我有哪一个?
How can I determine which one I've got?
推荐答案
您可以查看班级名称。例如:
You could look at the class name. For example:
<c:if test="${item.class.simpleName == 'String'}">
<!-- it's a String! -->
</c:if>
这篇关于如何检查JSTL对象是String还是Collection?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文