Jsp 如何使用JSTL读取arrayList内容
我想从JSTL读取分配给请求对象的arrayList对象属性 我该怎么做? 我尝试了以下方法 以下是servlet代码:Jsp 如何使用JSTL读取arrayList内容,jsp,servlets,jstl,Jsp,Servlets,Jstl,我想从JSTL读取分配给请求对象的arrayList对象属性 我该怎么做? 我尝试了以下方法 以下是servlet代码: ArrayList<Employee> al = new ArrayList<Employee>(); /* code for filling the ArrayList with objects from class Employee */ request.setAttribute("alldata", al);` ArrayList al=new
ArrayList<Employee> al = new ArrayList<Employee>();
/* code for filling the ArrayList with objects from class Employee */
request.setAttribute("alldata", al);`
ArrayList al=new ArrayList();
/*用于使用Employee类中的对象填充ArrayList的代码*/
setAttribute(“所有数据”,al)`
在我的JSP页面中:
<jsp:useBean id="alldata" class="java.util.ArrayList" scope="request">
<c:forEach items="alldata" var="item">
<c:out value="item.getName()"></c:out>
</c:forEach>
</jsp:useBean>
但它不起作用
提前感谢应该是:
<c:forEach items="${alldata}" var="item">
<c:out value="${item.name}"/>
</c:forEach>
注意:不需要
。使用EL表达式
<c:out value="${item.name}"></c:out>
我试过了,但我得到了以下异常:“根据标记文件中的TLD或属性指令,属性项不接受任何表达式”,这是我第一次体验JSTL:$谢谢skaffman@Developer_H:听起来您有一个非常旧的JSTL库版本,可能是1.0。您需要1.1或更高版本。事实上,是的,我使用的是1.0,我已将其更改为1.1,但得到了“javax.servlet.ServletException”:D似乎我在其他地方遇到了不兼容问题(有什么想法吗?)。。我现在查一下,谢谢你的帮助