NutzCN Logo
问答 我用NTZ框架,如何在JSP页面中使用DAO?
发布于 978天前 作者 wx_chrohf6r75suj7q2r8fh 1129 次浏览 复制 上一个帖子 下一个帖子
标签:

直接在<%%>使用Dao dao;报没有初始化,初始化为NULL执行报错,这个该怎么玩?,谢谢

3 回复

我在公用的一个JAVA中使用Dao,用GET/SET的方法使用,也报错

<%
             Sql sql;
             sql=Sqls.queryEntity("select distinct rtrim(cpname) as cpname from onumessage.cpk_cpsjk where xcpren='"+session.getAttribute("xm")+"' and iswc='0' and xcprenqx='"+session.getAttribute("qx")+"'");
             PublicProc publicProc=new PublicProc();

             sql.setEntity(publicProc.getDao().getEntity(cpsjk.class));
             publicProc.getDao().execute(sql);
             List<cpsjk> rs=sql.getList(cpsjk.class);
             String returnstr= "";
             if(rs.isEmpty())
                 System.out.println("暂时没有需完成的任务");
             else
                 for (cpsjk r : rs) returnstr = "你有一个" + r.getCpname().trim() + "没有完成,请在测评任务->完成测评任务中处理\r\n";
             System.out.println( returnstr);
             %>
Stacktrace:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:625)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:514)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	org.nutz.mvc.NutFilter.nextChain(NutFilter.java:230)
	org.nutz.mvc.NutFilter.doFilter(NutFilter.java:205)

Root Cause
java.lang.NullPointerException
	org.apache.jsp.display_jsp._jspService(display_jsp.java:150)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	org.nutz.mvc.NutFilter.nextChain(NutFilter.java:230)
	org.nutz.mvc.NutFilter.doFilter(NutFilter.java:205)

添加回复
请先登陆
回到顶部