【发布时间】:2016-01-24 09:04:28
【问题描述】:
我需要将一个对象转换为 Arraylist:
<% Arraylist<Products> mypr = sesion.getAttribute("products"); %>
<table class="table table-condensed">
<tr>
<th>Id</th>
<th>Category</th>
<th>Model</th>
<th>Stock</th>
<th>Price</th>
</tr>
<%
for (Products xx : mypr) {
out.println(xx.toString() + "<br>");
}
%>
【问题讨论】:
-
我不能使用我的“for”,因为它是一个对象而不是一个数组列表
-
session.getAttribute("products");
-
原来是
ArrayList吗? -
不,来自另一个 Servlet 的对象
-
显示来自该其他 servlet 的
setAttribute()代码