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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)