英文:
passing ArrayList from one JSP to another using session
问题
ArrayList<Object[]> custInfo = new ArrayList<Object[]>();
while(rs.next()){
String loginId = rs.getString("LOGIN_ID");
String customerId = rs.getString("CUSTOMER_ID") ;
String requestDate = rs.getString("REQUEST_DATE") ;
Object[] custInfo123 = {loginId, customerId, requestDate};
custInfo.add(custInfo123);
}
session.setAttribute("custInfo", custInfo);
在一个名为retreivedata.jsp
的 JSP 页面中,我使用了一个 ArrayList 来存储结果集的值,并设置了 session.setAttribute
。
在另一个名为 downloaddata.jsp
的 JSP 页面中,我使用了以下代码:
ArrayList<Object[]> custInfo = (ArrayList<Object[]>) session.getAttribute("custInfo");
但是这给了我一个错误,错误信息是 "ArrayList 无法解析为一种类型"。
英文:
ArrayList<Object[]> custInfo = new ArrayList<Object[]>();
while(rs.next()){
String loginId = rs.getString("LOGIN_ID");
String customerId = rs.getString("CUSTOMER_ID") ;
String requestDate = rs.getString("REQUEST_DATE") ;
Object[] custInfo123 = {loginId, customerId, requestDate};
custInfo.add(custInfo123);
}
session.setAttribute("custInfo", custInfo);
in one jsp retreivedata.jsp im using arraylist to store values of result set and set session.setAttribute.
and in other jsp downloaddata.jsp im using,
ArrayList<Object[]> custInfo = (ArrayList<Object[]>)session.getAttribute("custInfo");
but it has given me error ArrayList can not be resolved to a type.
答案1
得分: 1
Add import statement for ArrayList.
import java.util.ArrayList;
Update
For importing ArrayList in JSP, use the following syntax:
<%@ page import="java.util.ArrayList" %>
英文:
Add import statement for ArrayList.
import java.util.ArrayList;
Update
For importing ArrayList in jsp, use following syntax:
<%@ page import="java.util.ArrayList" %>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论