开发者

access hashmap in jsp

开发者 https://www.devze.com 2023-02-09 19:03 出处:网络
<c:forEach var = \"cart\" items= \"${cartx.items}\"> <tr bgcolor=\"${(i%2) ? \"#EFF3FB\" : \"White\" }\">
         <c:forEach var = "cart" items= "${cartx.items}"> 
            <tr bgcolor="${(i%2) ? "#EFF3FB" : "White" }">
                <td><c:out value = "${cart.key.tilte }"/></td>
                <td><c:out value = "${cart.key.price }"/><开发者_如何学Python/td>
                <c:set var = "price" value="${price}"></c:set>
                <c:set var="i" value = "${i+1 }"/>
            </tr>
         </c:forEach>

in this code snippet i want to access cartx which is a session variable and it contains list of book objects where book is a class.

i want to print the title and price of book which are the members of book class.


Maps are accessed in JSTL like that: ${map[key]}. (if key is an attribute as well)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号