开发者

Jsp iterate through object list

I'm having troubles iterating with jsp trough list/lists. Here is my object class called Table:

public class Table{

private String name;
private List<String> columns;
private List<Row> rows;

... continuing with getters and setters nothing more here

}

In my Row class I have just Strings(ex: String name), no lists no nothing.

Currently I have some List<Table> and I'm iterating trough it like this:

<c:forEach var='table' items='${requestScope.tables}'>
        <c:out value="{table.name}"></c:out>
</c:forEach>

Just for testing .. and it prints just {table.name} x times(the correct number of table objects in the table list).

My final goal is something like this (pseudo code):

for each table in table list
     print name
     for each column in colum list
         print column
     end co开发者_StackOverflow中文版lumn list for
     for each Row in row list
         print Row.name
     end row list for
end table list for

Could someone help me out with syntax?


<c:forEach var="table" items='${requestScope.tables}'>
        <c:out value="${table.name}"></c:out>

        <c:forEach var="column" items='${table.columns}'>
           <c:out value="${column}"></c:out>
        </c:forEach>

        <c:forEach var="row" items='${table.rows}'>
           <c:out value="${row.name}"></c:out>
        </c:forEach>

</c:forEach>


You forgot the dollar sign - ${table.name}
Also, you should use double-quotes: var="table"

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜