我的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>
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>
解决方案 »
- Java项目中jsp页面取不到表单中hidden标签里的值
- .net与java的区别
- 我托朋友问一下他的熟人公司用什么框架,没想到张口要钱...
- 在spring中 使用 spring 的DaoSupport,怎么释放数据库的连接呢?
- Tomcat5.5连SQL2000+pack4启动抛异常,不知道哪里出问题了,急死了~~~~
- 如何为String对象写一个自己的方法myMethod() ?
- struts高手请进
- 新学ejb,问个简单问题
- c3po+mysql报错You can't operate on a closed Statement!!!
- 为什么需要使用类加载器getClassLoader
- java实现接收文件的功能
- java做一个商品类别价格的统计
HttpSession httpSession = request.getSession();
httpSession.setAttribute("infoTable",pInfoTable);例如你得到了list,在action中只需要写request.getSession.setAttribute("list",list)然后你在前台直接就可以get得到这个list然后遍历它得到数据
你得到的应该是个list把,没遍历这样写得不到数据的,应该遍历下,例如
<%
while(view.hastNext()){
map = (Map)view.hastNex();
%>
<%=map.get("name")%>
<%}%>
request.getSession.setAttribute("infoTable",InfoTable);这样试试HttpSession是servlet自带的对象,你没必要自己专门去声明了