在我的action中有如下代码:
request.setAttribute("conn",conn);
return mapping.findForward("toTable");它对应的forword
         <forward name="toTable" path="/selectTable.do" />那我在SelectTableAction中
Connection conn=(Connection)request.getAttribute("conn");
获得的是null也就是conn没有传过来,这是为什么啊?

解决方案 »

  1.   

    顺便再问一下,这样子的话SelectTable对应的actionForm是不是就没有用呢?
      

  2.   

       1.  Boolean teamUser = true;  
       2. Boolean doEdit = false;  
       3.              
       4. return new ActionForward("/myaction.do?userid="+userid + "&teamUser="+teamUser + "&doEdit="+doEdit); 这样转好了    
      

  3.   

      QQ群:55046759  
      Jboss Struts Spring Hibernate DB javascript jquery 等相关技术讨论
      

  4.   

    其实你的前一个action如果有conn的get ,set方法,并且赋了值,那么转向的这个action也写一样的conn 的get,set,在execute里就可以调用get得到把,,不知道我说的对不对
      

  5.   

    前一个action中没有conn的set和get
    conn是在前一个action中生成的
      

  6.   

    参数传递不过去,猜测mapping.findForward()是重定向过去的.
    手头没有STRUTS的东西 你找一下STRUTS中findForward()方法的代码看看。
      

  7.   

    是因为服务端转向
    Connection conn=(Connection)request.getAttribute("conn"); 这个是肯定得不到数据的 
    你可以放在session里面 或者
      

  8.   

    如果是重定向转发的话,那么request里面的东西是得不到了,不知道楼主是不是重定向了?
      

  9.   

    楼主使用的是<forward name="toTable" path="/selectTable.do" /> 
    没有使用<forward name="toTable" path="/selectTable.do" redirect="true"/>
    因此不是重定向,我怀疑conn在request.setAttirbute()之前就是null.