我使用的是dao设计模式,其中我返回了一个arraylist对象,在对象内部我可以通过将对象类型转换为类来获取对象,并像object.getName()那样获取getter,我想使用jstl标签进行编程。我该怎么做。
<c:forEach items="${yourArrayList}" var="item">
<c:out value="${item.name}" />
</c:forEach>
The objects you put in your collection should conform to the JavaBeans specification (for ex. all of their properties should be accessible via getter methods).
${yourArrayList}
is actually a request attribute that you have put from a servlet and then forwarded to the jsp.
Ok with Bozho.
I will just say that if you redirect a servlet to jsp (which is better than calling dao from scriptlets...) don't forget to put your object that will be used in jstl in a pagecontext scope like request or session. Without that jstl lib would never find your object...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.