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

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

图片说明
--------------------------------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
    这个正确,别的都没有,是吧。在程序中下断点调试看看返回的列表中有没有,另外你的页面表达式绑定有没有问题

    评论

报告相同问题?

悬赏问题

  • ¥30 STM32 INMP441无法读取数据
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境