开发者

JSTL tag for accessing an arraylist so that it can be filled in a list box

开发者 https://www.devze.com 2023-03-28 03:14 出处:网络
I have seen two questions relating to my topic on stackoverflow, but those answers did not work for me, hence this question. I have the following object

I have seen two questions relating to my topic on stackoverflow, but those answers did not work for me, hence this question. I have the following object

public class CartProduct {
private ArrayList<String> accList = new ArrayList<String>();
public void setAccList(ArrayList<String> str)
{
this.accList = str;
}

public ArrayList<String> getAccList()
{
return accList;
}

I am using the following code to access this list and then its individual items using JSTL so that th开发者_如何学Cey can populate a list box in a JSP. But this code is not working and I dont seem to understand why?

<td><select name = "acc_no">
<Option value = "select">SELECT</Option>
<c:forEach items="${item.product.accList}" var="acno">
<option>${acno}</option>

</c:forEach>


</select>

The list box is empty except for the SELECT word.


The JSTL code looks fine. The JSP page is simply not accessing the instance you think it is accessing.


Check how you are sending the Customer class in the jsp page and check if the accList is empty or not?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号