EASONLEELEE 2015-04-15 06:21 采纳率: 22.2%
浏览 7564

后台到数据库可以查到值,但是,前台却不显示值,但是又一行记录,这是为什么?

图片说明
--------------------------------listProducts.jsp------------------------------------

    <table  class="table table-striped" width="1024">
        <thead>
            <tr>
                <th>商品全称</th>
                <th>品牌</th>
                <th>生产厂家</th>
                <th>计量单位</th>
                <th>零售价</th>
                <th>所属分类</th>
                <th>操作</th>
            </tr>
        </thead>
            <c:forEach items="${cs}" var="b">
                <tr>
                    <td>${b.name}</td>
                    <td>${b.brand}</td>
                    <td>${b.address}</td>
                    <td>${b.unit}</td>
                    <td>${b.outprice}</td>
                    <td>${b.category_id}</td>
                    <td>
                        <a href="javascript:delOne('${b.id}')">详细参数</a>
                        <a href="${pageContext.request.contextPath}/servlet/ManagerServlet?operation=editCategory&categoryId=${b.id}">修改</a>
                        <a href="javascript:delOne('${b.id}')">删除</a>
                    </td>
                </tr>
            </c:forEach>

        </table>

-------------------------- ManagerServlet------------------------------

 public class ManagerServlet extends HttpServlet {
    private BusinessService s = new BusinessServiceImpl();

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String operation = request.getParameter("operation");
        if("showAllProduct".equals(operation)){
            showAllProduct(request, response);
        }
    }

    private void showAllProduct(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

        List<Product> cs = s.findAllProducts();
        request.setAttribute("cs", cs);
        request.getRequestDispatcher("/manager/listProducts.jsp").forward(request, response);   

    }
        public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }
    }

----------------------------BusinessServiceImpl.java----------------------

 public class BusinessServiceImpl implements BusinessService {
    private ProductDao pDao = new ProductDaoImpl();
        public List<Product> findAllProducts() {
        return pDao.findAll();
    }
    }

------------------------------------ProductDaoImpl.java-------------------------

 public class ProductDaoImpl implements ProductDao {
    private QueryRunner qr = new QueryRunner(DBCPUtil.getDataSource());
    public List<Product> findAll() {
        try {
            return qr.query("select * from product", new BeanListHandler<Product>(Product.class));
        } catch (SQLException e) {
            throw new DaoException(e);
        }
    }
  • 写回答

2条回答

  • threenewbee 2015-04-15 06:41
    关注

    b.category_id
    这个正确,别的都没有,是吧。在程序中下断点调试看看返回的列表中有没有,另外你的页面表达式绑定有没有问题

    评论

报告相同问题?

悬赏问题

  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接