public ActionForward allCart(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
HttpSession session = request.getSession();
CartDAO dao = new CartDAO();
if (session.getAttribute("userid") != null) {
String userid = session.getAttribute("userid").toString(); Set set = dao.loadCart(userid);
if (set.size() < 1) {
request.setAttribute("number", "null");
}
request.setAttribute("produset", set);
System.out.println("list    " + set);
return mapping.findForward("cart");
} else
return mapping.findForward("index");
}   传不了值
 request.setAttribute("produset", set);改成session 就可以  为什么?“?
  帮我看看  

解决方案 »

  1.   

    request只是单纯的一次请求,这次请求响应完毕,本次实例就销毁了, session会话作用域比request大,可以跟踪多次响应
      

  2.   

    首先确定你的config.xml中action配置是不是request  ..
    再看:<forward name="" path="" redirect="false"></forward>
    redirect是不是false  ..
    redirect的值 :true表示  redict(不绑定值) false表示:forward(绑定值)
    这个可能性很大..
      

  3.   

    是指 :scope  默认应该是:request
      

  4.   


    是哦】
    我吧 redirect="false"设为真了
      重定向不能用request传值谢谢
      

  5.   

    document.getElementById("'+span+'").innerText=arr[1];
        span是变量  可以么??
      

  6.   

    request.setAttribute("produset", set);这个值只能在请求范围内获取   也就是说只能在forward情况下有效
    return mapping.findForward("index"); 
    这个转发需要看你的struts-congif.xml中的name为index的forward有没加redirect=true   有的话说明是重定向
    重定向后是没有传递原来的request对象的     而是重新创建了一个request对象  那么你再获取值的时候就无法获取到了而session针对的是整个应用程序中的会话期间内任何页面   任何时候都有效
    这也就是通常用它来做用户是否已经登陆的判断的主要原因