在做Struts的时候,我在SearchAction中将查找的结果(List类型的变量)保存在request中,然后再跳转。但是我在跳转的目标页面却找不到这个变量,提示说不存在。请问一下:为什么会出现这种情况?
代码如下:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
.....
List<Tel> list = teldao.searchByCondition(searchForm.getCondition(), pid);
request.setAttribute("result", list);
return mapping.findForward(ConstantVar.show_result);
}
目标页面:
<logic:iterate id="tel" name="result">
<tr>
<td>
<bean:write name="tel" property="id" />
</td>
<td>
<bean:write name="tel" property="name" />
</td>
<td>
<bean:write name="tel" property="telphone" />
</td>
<td>
<bean:write name="tel" property="address" />
</td>
</tr>
</logic:iterate>
代码如下:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
.....
List<Tel> list = teldao.searchByCondition(searchForm.getCondition(), pid);
request.setAttribute("result", list);
return mapping.findForward(ConstantVar.show_result);
}
目标页面:
<logic:iterate id="tel" name="result">
<tr>
<td>
<bean:write name="tel" property="id" />
</td>
<td>
<bean:write name="tel" property="name" />
</td>
<td>
<bean:write name="tel" property="telphone" />
</td>
<td>
<bean:write name="tel" property="address" />
</td>
</tr>
</logic:iterate>
应该是存在的 估计是你遍历的时候出现问题
<tr>
<td>
<bean:write name="tel" property="id" />
</td>
<td>
<bean:write name="tel" property="name" />
</td>
<td>
<bean:write name="tel" property="telphone" />
</td>
<td>
<bean:write name="tel" property="address" />
</td>
</tr>
</logic:iterate> </logic:present>