JSP-将数组数据从Java获取到JSP中

问题描述:

我必须显示从DB到JSP的数据.我正在使用Spring MVC.我已经在Java的List中存储了数据.现在,我需要在JSP中访问此列表,并以表格形式显示它.

I have to display data fetched from DB to JSP. I am using spring MVC. I have stored data in List in java. Now i need to access this list in JSP and display it in tabular form.

数据需要以列表形式从列表和VO表示,列名称和行名称来自列表,以及对象的行/列的相应值. 例如

Data needs to represented in tabular form from List and VO, column names and row names coming from List and corresponding values for row/column from object. e.g

         Column1  Column2  Column3   Column4
Row1       A         B         C       D
Row2       E         F         G       H

如何通过Java在jsp中传递此列表和对象.

How can i pass this List and Object in jsp from java.

谢谢

  • 在servlet上处理它并将其存储在StringList<List<String>>

    将其设置为请求属性,将请求转发给jsp.

    Set it as attribute to request, forward request to jsp.

    使用JSTL表示数据.使用<c:forEach>

    on jsp use JSTL to represent data. using <c:forEach>