Limit℃ 2019-04-23 16:48 采纳率: 0%
浏览 504

request往jsp页面传输数据为null,但是xml的url路径下是有数据的

//servlet
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html;charset=UTF-8");
List productList=null;
try {
productList = service.FindAllProduct();
} catch (SQLException e) {
e.printStackTrace();
}
if(productList!=null) {
//request域中存数据
req.setAttribute("productList", productList);
//转发给jsp
req.getRequestDispatcher("/admin/product/list.jsp").forward(req, resp);
}else{
System.out.println("查询失败");
}
}

    //jsp
    <%
                            System.out.println(request.getAttribute("productList"));
                        %>
                        <c:forEach items="${requestScope.productList}" var="product" varStatus="vs">
                            <tr onmouseover="this.style.backgroundColor = 'white'"
                                onmouseout="this.style.backgroundColor = '#F5FAFE';">
                                <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                                                          width="18%">${vs.count}</td>
                                <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                                    width="17%"><img width="40" height="45" src="${pageContext.request.contextPath}/${product.pimage}"></td>
                                <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                                    width="17%">${product.pname}</td>
                                <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                                    width="17%">product.shop_price</td>
                                <td style="CURSOR: hand; HEIGHT: 22px" align="center"
                                    width="17%">${product.is_hot==1?"是":"否"}</td>
                                <td align="center" style="HEIGHT: 22px"><a
                                        href="${ pageContext.request.contextPath }/admin/product/edit.jsp">
                                    <img
                                            src="${pageContext.request.contextPath}/images/i_edit.gif"
                                            border="0" style="CURSOR: hand">
                                </a></td>
                                <td align="center" style="HEIGHT: 22px"><a href="#"> <img
                                        src="${pageContext.request.contextPath}/images/i_del.gif"
                                        width="16" height="16" border="0" style="CURSOR: hand">
                                </a></td>
                            </tr>
                        </c:forEach>
  • 写回答

1条回答 默认 最新

  • huxin889 2019-04-23 22:40
    关注

    debug一下productList = service.FindAllProduct(); 这个productList是不是空的,可能是解析XML的问题

    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题