[英]Servlet ArrayList to JSP (Uncheked cast from Object to ArrayList)
i tried everything i saw, but without success, if someone can help with that, ooh man .. 我尝试了我所看到的一切,但没有成功,如果有人可以帮助,哦,男人......
The problem is that: I cant put a arraylist to jsp from servlet with success, eclipse shows me in JSP that:Uncheked cast from Object to ArrayList, 问题是:我不能成功地将一个arraylist从servlet放到jsp中,eclipse在JSP中向我显示:Uncheked从Object转换为ArrayList,
thats my Servlet Code 这就是我的Servlet代码
filhoArray = dao.consultar_cpf(mae);
request.setAttribute("filho", filhoArray);
getServletConfig().getServletContext().getRequestDispatcher("/resultado-consulta.jsp").forward(request,response);
and JSP 和JSP
Bebe bebe = new Bebe();
ArrayList<Bebe> list = (ArrayList<Bebe>) request.getAttribute("filho");
System.out.println(list);
out.print(list);
This is a warning that you are casting from a non-generic type to a generic type. 这是一个警告 ,表明您正在从非泛型类型转换为泛型类型。 In your special situation you can't avoid this cast and therefore you can silence the warning by writing: 在您的特殊情况下,您无法避免此演员表,因此您可以通过以下方式使警告静音:
@SuppressWarnings("unchecked")
ArrayList<Bebe> list = (ArrayList<Bebe>) request.getAttribute("filho");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.