[英]Servlet ArrayList to JSP (Uncheked cast from Object to ArrayList)
我嘗試了我所看到的一切,但沒有成功,如果有人可以幫助,哦,男人......
問題是:我不能成功地將一個arraylist從servlet放到jsp中,eclipse在JSP中向我顯示:Uncheked從Object轉換為ArrayList,
這就是我的Servlet代碼
filhoArray = dao.consultar_cpf(mae);
request.setAttribute("filho", filhoArray);
getServletConfig().getServletContext().getRequestDispatcher("/resultado-consulta.jsp").forward(request,response);
和JSP
Bebe bebe = new Bebe();
ArrayList<Bebe> list = (ArrayList<Bebe>) request.getAttribute("filho");
System.out.println(list);
out.print(list);
這是一個警告 ,表明您正在從非泛型類型轉換為泛型類型。 在您的特殊情況下,您無法避免此演員表,因此您可以通過以下方式使警告靜音:
@SuppressWarnings("unchecked")
ArrayList<Bebe> list = (ArrayList<Bebe>) request.getAttribute("filho");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.