al.size()  出现的空指针 也就是 al 为null 了、也就是ArrayList al=(ArrayList)request.getAttribute("mycartinfo"); 这行没有获取到数据al = null 了、doGet 方法里、ArrayList al=mcb.showMyCart(); 这句你debug 看下能获取到null 不?

解决方案 »

  1.   

    下次建议把报错的语句给贴上来,要不找错误的话得从头看到尾了。
    al放入request中了,跳转到shopping3.jsp的时候不知道有没有把al从request中取出来。
    我也刚学这个,说的不对的请多指教。
      

  2.   


    接2楼的
    jsp中
    加上这句话<s:debug></s:debug>,
    然后看看ValueStack中有木有
      

  3.   

    //2.把购物车的信息取出
    MycartBo mcb=(MycartBo)request.getSession().getAttribute("mycart");
    ArrayList al=mcb.showMyCart();
    //把al放入request
    request.setAttribute("mycartinfo", al);