我在從會話中檢索和投射ArrayList時遇到問題。我收到以下錯誤:Session對象中的ArrayList似乎丟失了內容
javax.servlet.ServletException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
我存儲在ArrayList中的會話:
List<UserApplication> userList = uaDAO.searchUser(eds);
if (!userList.isEmpty()) {
request.getSession().setAttribute("userList", userList);
action_forward = EDITSUCCESS;
和鑄造會話對象ArrayList中,做了以下內容:
EditStudentForm edt = (EditStudentForm)form;
if ((session.getAttribute("userList")) instanceof List){
List <UserApplication> studtList = (ArrayList<UserApplication>)session.getAttribute("userList");
}
try {
uaDAO.editUser(edt,studtList);
action_forward = EDITSUCCESS;
}
我m在DAO類中得到這裏的錯誤:
public void editUser(EditStudentForm edt,List studtList) throws Exception {
PreparedStatement pst = null;
StringBuilder sb = new StringBuilder();
int stCode =Integer.parseInt(studtList.get(1).toString()); GETTING ERROR HERE
if (edt.getTitle() != null && !edt.getTitle().equals(studtList.get(2).toString())) {
sb.append("title = '").append(edt.getTitle()).append("'");
}
.
.
請修改您的標題。 – entonio 2013-02-15 18:42:14
謝謝大家的幫助。 – javaStudent 2013-02-15 19:08:15
你好,看起來像鑄造不工作。有人請告訴我我做錯了什麼? – javaStudent 2013-02-15 19:35:53