service

Mr.趁早! 2014-07-19 02:56:06
service方法都对 jsp页面的不到正确的返回值
service:
public List<PersonInfo> zhuXiaoByName(String zhuXiaoName){

Session session0=HibernateSessionFactory.getSession0();
session0.clear();
String hql="from PersonInfo where state=0 and name like '%"+zhuXiaoName+"%'";
Query query=session0.createQuery(hql);
List<PersonInfo> zhuList=query.list();
session0.close();
return zhuList;
}
action:
public ActionForward checkZhuXiaoName(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)throws Exception{

String zhuXiaoName=request.getParameter("zhuXiaoName");
List<PersonInfo> zhuList=personInfoService.zhuXiaoByName(zhuXiaoName);
HttpSession session=request.getSession();
session.setAttribute("zhuList", zhuList);
session.setAttribute("zhuXiaoName", zhuXiaoName);
return mapping.findForward("zhuXiaoName");
}
jsp:
<%
List<PersonInfo> arr=(List<PersonInfo>)session.getAttribute("zhuList");
if (arr.size() == 0) {
%>
<tr>
<td colspan="15" class="td2" bgcolor=#FFFFFF>
<center>
暂无信息显示!
</center>
</td>
</tr>
<%
} else {
for (int i = 0; i < arr.size(); i++) {
PersonInfo personInfo = (PersonInfo) arr.get(i);
%>
<%=personInfo.getName() %>

<%}
}%>


求大神
...全文
129 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧