怎样在JSP页面上显示HQL查询结果
lookareaDaoImpl.java代码publicListlookarea(Stringtype){try{queryString="selectsps.id.ar...
lookareaDaoImpl.java代码
public List lookarea(String type){ try { queryString="select sps.id.areaname,count(*)from SpsUserservice as sps where status=0 and servicetype=? group by sps.id.areaname"; Query query=session.createQuery(queryString); query.setParameter(0, type); return query.list(); } catch (RuntimeException re) { re.printStackTrace(); throw re; }}
lookareaDaoImpl.java代码public class lookareaAction extends DispatchAction { lookareaBiz biz=new lookareaBizImpl(); public ActionForward dolookArea(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try{ String servtype=request.getParameter("type"); List look=biz.lookarea(servtype); request.setAttribute("lookarea",look); return mapping.findForward("lookarea"); }catch(Exception e){ return mapping.findForward("index.jsp"); } }}
怎么样子在JSP页面上显示出我这查询的结果?麻烦各位高手知道下,小弟感激不尽 展开
public List lookarea(String type){ try { queryString="select sps.id.areaname,count(*)from SpsUserservice as sps where status=0 and servicetype=? group by sps.id.areaname"; Query query=session.createQuery(queryString); query.setParameter(0, type); return query.list(); } catch (RuntimeException re) { re.printStackTrace(); throw re; }}
lookareaDaoImpl.java代码public class lookareaAction extends DispatchAction { lookareaBiz biz=new lookareaBizImpl(); public ActionForward dolookArea(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try{ String servtype=request.getParameter("type"); List look=biz.lookarea(servtype); request.setAttribute("lookarea",look); return mapping.findForward("lookarea"); }catch(Exception e){ return mapping.findForward("index.jsp"); } }}
怎么样子在JSP页面上显示出我这查询的结果?麻烦各位高手知道下,小弟感激不尽 展开
2013-08-30
展开全部
好乱的代码,看得头晕!大概看清你的问题了!你可以这样子写:先在你的lookareaAction. Java里面用request.getSession().setAttribute("lookarea", look);然后在JSP页面里加上: <% List list=(List)request.getSession().getAttribute("lookarea"); Iterator it=list.iterator(); while(it.hasNext()){ Object[] obj=(Object[])it.next();%> <tr> <td><%=obj[0]%></td> <td><%=obj[1]%></td> </tr> <%}%>这样就可以了,去试试看。
2013-08-30
展开全部
在页面的头部导入你要用到得类:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="com.包名"%>
在页面写入小脚本
<%
这里写Java代码,如:实例化你的类,再调用你的方法
%>
这里写HTML元素
<%
小脚本的结束
%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="com.包名"%>
在页面写入小脚本
<%
这里写Java代码,如:实例化你的类,再调用你的方法
%>
这里写HTML元素
<%
小脚本的结束
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询