Jsp 如何在JSTL中显示多维数组?

Jsp 如何在JSTL中显示多维数组?,jsp,jstl,Jsp,Jstl,我有这门课 public class Step { public int x; public int y; public int id; } 我的servlet创建了一个二维数组,如下所示: Step[][] steps = new Step[size][size]; request.setAttribute("gamesSteps", steps); request.getRequestDispatcher("/game.jsp").forwar

我有这门课

public class Step {
    public int x;
    public int y;
    public int id;
}
我的servlet创建了一个二维数组,如下所示:

Step[][] steps = new Step[size][size];
request.setAttribute("gamesSteps", steps);          
request.getRequestDispatcher("/game.jsp").forward(request, response);
< c:forEach items="${requestScope.gamesSteps}" var="steps"> 
    < c:forEach items="${steps}" var="step">                   
        < c:out value="${step.id} "/>       
    < /c:foreach>     
< /c:forEach>
有些步骤是
null
,有些步骤不是
null
。然后它转发到JSP,如下所示:

Step[][] steps = new Step[size][size];
request.setAttribute("gamesSteps", steps);          
request.getRequestDispatcher("/game.jsp").forward(request, response);
< c:forEach items="${requestScope.gamesSteps}" var="steps"> 
    < c:forEach items="${steps}" var="step">                   
        < c:out value="${step.id} "/>       
    < /c:foreach>     
< /c:forEach>
在JSP中,我将它们显示如下:

Step[][] steps = new Step[size][size];
request.setAttribute("gamesSteps", steps);          
request.getRequestDispatcher("/game.jsp").forward(request, response);
< c:forEach items="${requestScope.gamesSteps}" var="steps"> 
    < c:forEach items="${steps}" var="step">                   
        < c:out value="${step.id} "/>       
    < /c:foreach>     
< /c:forEach>






但是什么也没有出现。这是如何导致的,我如何解决它?

您需要为属性使用getter方法

为你们班干杯


您必须遵守JavaBeans规范。

您有一些键入错误。这样试试看

<c:forEach items="${requestScope.gamesSteps}" var="steps"> 
<c:forEach items="${steps}" var="step">                   
    <c:out value="${step.id} "/>       
</c:forEach>     
</c:forEach>


我相信OP在发现“代码格式”按钮之前,在试图找出如何让HTML代码显示在堆栈溢出问题预览中时故意插入了它们,但后来忘了删除空白。因此,这只是一个转移视线的问题。我指的是,它对小e不起作用,