我的Action如下:
public class EditDeployAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)  throws Exception
{
......
//将查询到的数据写入到session中,供页面使用
HttpSession httpSession = request.getSession();
httpSession.setAttribute("infoTable",pInfoTable);//pInfoTable为PlanSunProject的一个实例 ......

}
}我的页面代码如下,可是不能得到结果。谢谢
<body>
<form action="../../rzgs.do" enctype="multipart/form-data" method="post" id="inFrm" name="inFrm" target="mainwindow">
  <% 
      if(request.getSession().getAttribute("infoTable")!=null)
      {
      
       PlanSunProject pInfoTable=(PlanSunProject)request.getSession().getAttribute("infoTable");//得到pInfoTable对象
      }
    %>
   
    <script language="javascript">
    alert(<%=String.valueOf(pInfoTable.getBuildingcompany())%>);
</script>  <tr>
    <td width="105" height="31"><font color='#003366' size='2'>项目名称:</td>
    <td width="212"><textarea id="location"  style="width:160px" name="projectName">
     <%=pInfoTable.getProjectname()%></textarea></td>
  </tr><input id="submitok" type="button" name="Submit" value="提交" onclick="SubmitOK()" /> 
<input id="reset" type="reset" name="reset" value="重填"/>
</form>
</body>

解决方案 »

  1.   

    你在写Action的的时候,没看见HttpServletRequest request, HttpServletResponse response这个吗?怎么又写
    HttpSession httpSession = request.getSession();
    httpSession.setAttribute("infoTable",pInfoTable);例如你得到了list,在action中只需要写request.getSession.setAttribute("list",list)然后你在前台直接就可以get得到这个list然后遍历它得到数据
      

  2.   


    你得到的应该是个list把,没遍历这样写得不到数据的,应该遍历下,例如
    <%
    while(view.hastNext()){
    map = (Map)view.hastNex();
    %>
    <%=map.get("name")%>
    <%}%>
      

  3.   

    楼主写的代码,我没发现有什么问题
    request.getSession.setAttribute("infoTable",InfoTable);这样试试HttpSession是servlet自带的对象,你没必要自己专门去声明了
      

  4.   

    pInfoTable 这个里面有记录 是一个对象,不是数组。能不能将我的页面代码改动一下,我好试试。谢谢