logic:iterate标签问题 我在JSP中使用了logic:iterate标签,一直没有数据显示出来,请大家帮我看看
<logic:emptyname="userInfoList"scope="request"><center><h3>抱歉:没有您的信息</h3></center></l...
<logic:empty name="userInfoList" scope="request">
<center><h3>抱歉:没有您的信息</h3></center>
</logic:empty>
<table align="center" border="1">
<logic:notEmpty name="userInfoList" scope="request">
<logic:iterate id="student" name="userInfoList" scope="request">
<tr>
<th width="33.3%">帐号</th>
<th width="33.3%">昵称</th>
<th width="33.3%">真实姓名</th>
</tr>
<tr>
<td width="33.3%"><bean:write name="student" property="ID"/></td>
<td width="33.3%"><bean:write name="student" property="userName"/></td>
<td width="33.3%"><bean:write name="student" property="trueName"/></td>
</tr>
<tr>
<th width="33.3%">电话号码</th>
<th width="33.3%">详细地址</th>
<th width="33.3%">电子邮箱</th>
</tr>
<tr>
<td width="33.3%"><bean:write name="student" property="phone"/></td>
<td width="33.3%"><bean:write name="student" property="address"/></td>
<td width="33.3%"><bean:write name="student" property="email"/></td>
</tr>
</logic:iterate>
</logic:notEmpty>
</table>
action中方法:
public ActionForward checkUserInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
HttpSession session=request.getSession();
String userName=(String)session.getAttribute("userName");
if(userName==null||userName.equals(""))//若用户为空
return mapping.findForward("fail");
Map map=new HashMap();
map.put("userName",userName);
UserDao dao=new UserDaoSimple();
List list=new ArrayList();
list=dao.queryArray(map);//学生查询
request.setAttribute("userInfoList", list);//将查询结果放入request中
return mapping.findForward("studentInfo");//将数据返回查询页
} 展开
<center><h3>抱歉:没有您的信息</h3></center>
</logic:empty>
<table align="center" border="1">
<logic:notEmpty name="userInfoList" scope="request">
<logic:iterate id="student" name="userInfoList" scope="request">
<tr>
<th width="33.3%">帐号</th>
<th width="33.3%">昵称</th>
<th width="33.3%">真实姓名</th>
</tr>
<tr>
<td width="33.3%"><bean:write name="student" property="ID"/></td>
<td width="33.3%"><bean:write name="student" property="userName"/></td>
<td width="33.3%"><bean:write name="student" property="trueName"/></td>
</tr>
<tr>
<th width="33.3%">电话号码</th>
<th width="33.3%">详细地址</th>
<th width="33.3%">电子邮箱</th>
</tr>
<tr>
<td width="33.3%"><bean:write name="student" property="phone"/></td>
<td width="33.3%"><bean:write name="student" property="address"/></td>
<td width="33.3%"><bean:write name="student" property="email"/></td>
</tr>
</logic:iterate>
</logic:notEmpty>
</table>
action中方法:
public ActionForward checkUserInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
HttpSession session=request.getSession();
String userName=(String)session.getAttribute("userName");
if(userName==null||userName.equals(""))//若用户为空
return mapping.findForward("fail");
Map map=new HashMap();
map.put("userName",userName);
UserDao dao=new UserDaoSimple();
List list=new ArrayList();
list=dao.queryArray(map);//学生查询
request.setAttribute("userInfoList", list);//将查询结果放入request中
return mapping.findForward("studentInfo");//将数据返回查询页
} 展开
展开全部
页面顶部是否有对logic标签库的引入?
比如
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
如果还有问题,可以在action中看list是否为空。
比如
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
如果还有问题,可以在action中看list是否为空。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询