通过 jsp:param 传递的对象抛出 javax.el.PropertyNotFoundException: Property 'foo'在 java.lang.String 类型上找不到
我知道这可能是一个愚蠢的问题,我尝试谷歌搜索但没有得到完美的答案。
我正在使用以下代码
<c:forEach var="aggregatedBatchProgressMetrics" items="${batchProgressMetricsList}">
<jsp:include page="html/tableContentsDisplayer.jsp">
<jsp:param name="batchProgressMetrics" value="${aggregatedBatchProgressMetrics}" />
</jsp:include>
</c:forEach>
并在 html/tableContentsDisplayer.jsp 中,我
<c:set var="aggregatedBatchProgressMetrics">${param.batchProgressMetrics}</c:set>
<tr>
<td class="tdcenter">${aggregatedBatchProgressMetrics["clientId"]}</td>
<td class="tdcenter">${aggregatedBatchProgressMetrics["instrumentStats"]["totalImntsCompleted"]}</td>
<td class="tdcenter">${aggregatedBatchProgressMetrics["instrumentStats"]["totalImntsRemaining"]}</td>
</tr>
从 c:forEach 得到以下的aggregateBatchProgressMetrics 是 com.xyz.AggreeratedBatchProgressMetrics 类型的对象,而不是字符串,从例外情况来看,它将其视为字符串对象。我在 bean 中有 getClientId 方法。另外,如果我按原样放置包含的 jsp 文件的内容(没有指令和 c:set 标记),它绝对可以正常工作。有没有一种方法可以使用 jsp:param 标记传递对象,并在接收端将其作为对象获取?
是否可以使用 jstl 或者我必须使用 scriptlet/expression 来实现相同的目的?
谢谢, 阿尔马斯
I know this might be silly question and i tried googling but didnt got perfect answer.
I am using following code
<c:forEach var="aggregatedBatchProgressMetrics" items="${batchProgressMetricsList}">
<jsp:include page="html/tableContentsDisplayer.jsp">
<jsp:param name="batchProgressMetrics" value="${aggregatedBatchProgressMetrics}" />
</jsp:include>
</c:forEach>
and inside html/tableContentsDisplayer.jsp, i have following
<c:set var="aggregatedBatchProgressMetrics">${param.batchProgressMetrics}</c:set>
<tr>
<td class="tdcenter">${aggregatedBatchProgressMetrics["clientId"]}</td>
<td class="tdcenter">${aggregatedBatchProgressMetrics["instrumentStats"]["totalImntsCompleted"]}</td>
<td class="tdcenter">${aggregatedBatchProgressMetrics["instrumentStats"]["totalImntsRemaining"]}</td>
</tr>
aggregatedBatchProgressMetrics is what i get from c:forEach is an object of type com.xyz.AggregatedBatchProgressMetrics and not a String, from the exception it treats that as an String object. I have getClientId method inside the bean. Also if i place the content of included jsp file as is (without directives and c:set tag) it works absolutely fine. Is there a way i can pass an object using jsp:param tag and on the recieving end i get it as an object?
Is it possible using jstl or i will have to use scriptlets/expression for the same?
Thanks,
Almas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTP 请求参数被视为字符串。对于
jsp:param
来说,它基本上是通过String#valueOf()
转换为字符串的。而是在
的帮助下将其作为对象存储在请求范围中。HTTP request parameters are treated as strings. With
jsp:param
it's basically been converted to string byString#valueOf()
. Rather store it as object in the request scope with help of<c:set>
.