(index2.jsp)<body>
<div>
${not empty userList ? 'abc' : 'xxx' }
</div> <table>
<thead>
<tr>
<th>GID</th>
<th>GNAME</th>
<th>USERID</th>
<th>GPRICE</th>
<th>GTYPE</th>
<th>GNUMBER</th>
</tr>
</thead>
<tbody>
<c:forEach items="${userList}" var="u">
<tr>
<td>${u.GID}</td>
<td>${u.gname}</td>
<td>${u.UserId}</td>
<td>${u.gprice}</td>
<td>${u.gtype}</td>
<td>${u.gnumber}</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
...........................................................
(homeServlet.java)public class HomeServlet extends HttpServlet { /**
 * 
 */
private static final long serialVersionUID = 1L; @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException { // TODO 查询动态数据
String sql = "SELECT * FROM T_GOODS";
List<Map<String, Object>> users = DBUtils.query(sql);
req.setAttribute("userList", users);
req.getRequestDispatcher("index2.jsp").forward(req, resp);
}

}.........................
..................
然后页面就成这样了求指导,谢谢噢

解决方案 »

  1.   

    先看看你后台userList里面有值吗
      

  2.   

    用List<类名>接受试试。DBUtils的query方法怎么写的?
      

  3.   

    界面显示的为xxx
    所以userList 为空
    在方法中打印下userList 的大小
      

  4.   

    1.在jsp页面从request中把list取出来
    List userList = (List<Map<String, Object>>)request.getAttribute("userList");
    2.用双重循环取值
    <c:forEach items="${userList}" var="map">
    <c:forEach items="${map}" var="m">
    <tr>
    <td><c:out value="${m.key}" /></td>
    <td><c:out value="${m.value}" /></td>
    </tr>
    </c:forEach>
    </c:forEach>