【发布时间】:2011-02-01 03:04:34
【问题描述】:
我有一些扩展超类的类,在 JSP 中我想展示这些类的一些属性。我只想做一个JSP,但是事先不知道对象有没有属性。所以我需要一个 JSTL 表达式或一个标签来检查我传递的对象是否具有此属性(类似于 javascript 中的 in 运算符,但在服务器中)。
<c:if test="${an expression which checks if myAttribute exists in myObject}">
<!-- Display this only when myObject has the atttribute "myAttribute" -->
<!-- Now I can access safely to "myAttribute" -->
${myObject.myAttribute}
</C:if>
我怎样才能得到这个?
谢谢。
【问题讨论】: