SSH中,怎样在jsp页面调用hibernate的dao中的方法 20
dao为:publicTbMembergetUsername(Stringusername){Listlist=null;TbMemberuser=newTbMember...
dao为:
public TbMember getUsername(String username) {
List list = null;
TbMember user = new TbMember();
System.out.println(getHibernateTemplate());
list = getHibernateTemplate().find("from TbMember where userName='" + username + "'");
if(list !=null ){
System.out.println("==list==="+list);
if (list.size() > 0) {
user = (TbMember) list.get(0);
System.out.println("Dao.getUsername()=user="+user);
}
}
return user;
}
jsp为 TbMember u = dao.getUsername(username);
但是现在调用dao报错 哪位高手帮忙解答下
报错信息:
2010-7-27 16:25:58 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at com.lzw.dao.Dao.getUsername(Dao.java:63)
at org.apache.jsp.Validate_jsp._jspService(Validate_jsp.java:82)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
回答的高手顺便能把QQ留给我吗
我知道是空指针 但是我想问知道为什么报这个错 展开
public TbMember getUsername(String username) {
List list = null;
TbMember user = new TbMember();
System.out.println(getHibernateTemplate());
list = getHibernateTemplate().find("from TbMember where userName='" + username + "'");
if(list !=null ){
System.out.println("==list==="+list);
if (list.size() > 0) {
user = (TbMember) list.get(0);
System.out.println("Dao.getUsername()=user="+user);
}
}
return user;
}
jsp为 TbMember u = dao.getUsername(username);
但是现在调用dao报错 哪位高手帮忙解答下
报错信息:
2010-7-27 16:25:58 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at com.lzw.dao.Dao.getUsername(Dao.java:63)
at org.apache.jsp.Validate_jsp._jspService(Validate_jsp.java:82)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
回答的高手顺便能把QQ留给我吗
我知道是空指针 但是我想问知道为什么报这个错 展开
展开全部
JSP最好不要调用dao
都玩SSH 了
至少要有个三层吧 喜欢直接调后台?
都玩SSH 了
至少要有个三层吧 喜欢直接调后台?
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个是空指针异常,不是因为在jsp中调用出错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把包导入到JSP得项目中,或者导入到JSP得文件中,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
好神奇。。。。为啥不用dwr呢???
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
提问要有点水平,将出错信息贴出来,大家才好给你解决嘛
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询