这个 Servlet,我在 color car 上做 GROUP BY。插入到请求中并在 jsp 中做广告,但它不会转换。
Query query = session.createQuery("select count(carColor), carColor from Cars group by carColor order by carColor");
List<Cars> list = query.list();
Iterator iter = list.iterator();
while (iter.hasNext()) {
Object[] obj = (Object[]) iter.next();
System.out.println(obj[0] + " " + obj[1]);
}
request.setAttribute("list", list);
RequestDispatcher rd = request.getRequestDispatcher("test.jsp");
rd.forward(request, response);
控制台:2白10黑5蓝
JSP: [[Ljava.lang.Object;@1f3b536, [Ljava.lang.Object;@fdffb1,]]