Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
577 views
in Technique[技术] by (71.8m points)

parameter passing - Object passed via jsp:param throws javax.el.PropertyNotFoundException: Property 'foo' not found on type java.lang.String

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

HTTP request parameters are treated as strings. With jsp:param it's basically been converted to string by String#valueOf(). Rather store it as object in the request scope with help of <c:set>.

<c:forEach var="aggregatedBatchProgressMetrics" items="${batchProgressMetricsList}">  
    <c:set var="batchProgressMetrics" value="${aggregatedBatchProgressMetrics}" scope="request" />
    <jsp:include page="html/tableContentsDisplayer.jsp" />  
</c:forEach>

<tr>  
    <td class="tdcenter">${batchProgressMetrics["clientId"]}</td>    
    <td class="tdcenter">${batchProgressMetrics["instrumentStats"]["totalImntsCompleted"]}</td>  
    <td class="tdcenter">${batchProgressMetrics["instrumentStats"]["totalImntsRemaining"]}</td>
</tr>  

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...