我的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>
解决方案 »
- jsp中action怎么提交到Servlet
- 求一个开源java的bbs系统
- * 在HTML里代表什么?
- 请问eclipse-SDK-3.1-win32.zip 结合哪个版本的lomboz开发j2ee?
- 在windows xp 操作系统中能不能用jdbc 纯驱动访问sql2000数据库
- 实体Bean和sqlserver连接出现的问题,紧急求救~~~
- 在线等,急!关于LookupDispatchAction的问题
- eclipse+tomcat怎么配置啊,有没有中文的说明啊?
- 请问哪位大虾有关于“电子商务网上交易系统”的总体设计方案,提供一下!相关的资料也可以,谢谢!
- 我开了一个FTP服务器,大家有资料就上传上去吧!
- 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自带的对象,你没必要自己专门去声明了