当属性名称本身是JSP中的变量时,如何获取对象属性的值? [英] How to get a value of an object's property when the property name is a variable itself in JSP?
本文介绍了当属性名称本身是JSP中的变量时,如何获取对象属性的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI
这是我的难题.下面的代码显然是错误的,但是它使您对我需要完成的事情有了想法.
Here's my dilemma. The below code is obviously wrong but it give you the idea on what I need to accomplish.
<c:forEach var="object1" items="${model.listofObjects1}">
<tr>
<c:forEach var="object2" items="${model.listofObjects2}">
<td>${object1.${object2}}</td>
</c:forEach>
</tr>
</c:forEach>
关于如何进行查找的任何想法?
Any ideas on how to make this look up?
推荐答案
使用大括号表示法.
<td>${object1[object2]}</td>
这篇关于当属性名称本身是JSP中的变量时,如何获取对象属性的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文