我正在尝试获取所有记录形式的servlet并将其循环到jsp中 但我只得到最后一条记录
String[] SchoolName = request.getParameterValues("shoolname");
String[] DateFrom = request.getParameterValues("Dateform");
String[] DateTo = request.getParameterValues("Datato");
String[] DiscriptDetails = request.getParameterValues("Dscript");
for ( int i = 0 ; i < SchoolName.length;i++ ) {
educatiodetails edu = new educatiodetails();
edu.setSchoolName(SchoolName[i]);
edu.setDateFrom(DateFrom[i]);
edu.setDateTo(DateTo[i]);
edu.setDiscriptDetails(DiscriptDetails[i]);
EducatiIMP education = new EducatiIMP();
education.addEducation(edu);
HttpSession session = request.getSession(true);
addEducation.getList();
EducatiIMP ado = new EducatiIMP();
educatiodetails educat = ado.geteducatiodetails(SchoolName[i]);
session.setAttribute("educat",educat);
}
这是我的foreach循环的jsp代码,我刚得到 我的数据库的最后一个记录表格可以帮助任何人吗????
<c:forEach items="${educat.schoolName}" var="item" varStatus="state">
<h2><c:out value="${item}"/></h2>
</c:forEach>
can anyone please help me.....
答案 0 :(得分:0)
如果 $ {educat.schoolName} 当然是数组,则可以尝试以下操作:
...
<c:forEach items="${educat.schoolName}" var="item" varStatus="state">
<c:out value="${educat.schoolName[state.index]}"/>
</c:forEach>
...