代码为:
List<Map<String, Object>> shoplist=  getshop.getshops();
request.setAttribute("shops",shoplist);
System.out.println("商品信息 " + shoplist);
jsp中的代码片段:
<ul>
 <c:forEach items="${shops}" var="shop">
<li>
<p><a href="javascript:;"><img src="${shop.simg}"></a></p>
<p><a href="javascript:;" class="name">${shop.sname}</a></p>
<p class="price"><em>¥</em>
 ${shop.sprice}
</p>
</li>
</c:forEach>
</ul>其中用控制台输出list的内容为商品信息 [{sid=4, sclass=213, simg=./images/content_bottom.png, sdiscount=32, sprice=6546, sname=werwer, soldprice=234}, {sid=3, sclass=444, simg=./images/content_bottom.png, sdiscount=111, sprice=222, sname=qwe, soldprice=333}, {sid=2, sclass=1, simg=./images/content_bottom.png, sdiscount=2, sprice=22, sname=asd, soldprice=33}, {sid=1, sclass=1, simg=./images/content_bottom.png, sdiscount=1, sprice=22, sname=www, soldprice=33}]
但是最终效果是网页中c:forEach的片段输出空白,即使什么内容都没有,初学者,想不出哪里出了问题了,求大神打救

解决方案 »

  1.   

    首先该引入的jstl库都要引入;
    然后,c:forEach标签中,先不要任何其他标签,直接将想要的信息输出,看是否还是空白
      

  2.   

    list里边存的不是对象,所以无法通过.的方式拿到
      

  3.   

    问题解决了,原来是我犯了个低级错误,我将request.getRequestDispatcher("index.jsp").forward(request, response);代码写在request.setAttribute的上面了。
      

  4.   

    打印一下shoplist看看是否拿到了数据。或者直接在前端${shops}看看有没有输出,没有输出就是没有数据传过来