当前位置: 代码迷 >> Java Web开发 >> 空指针错误求帮助
  详细解决方案

空指针错误求帮助

热度:4882   发布时间:2013-02-25 21:06:01.0
空指针异常求帮助
出错提示
java.lang.NullPointerException
at com.tchManage.dao.PostDAO.findAllPost(PostDAO.java:39)
at com.tchManage.servlet.PostController.findAll(PostController.java:131)
at com.tchManage.servlet.PostController.doPost(PostController.java:40)
at com.tchManage.servlet.PostController.doGet(PostController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)



com.tchManage.dao.PostDAO.java
public List<Post> findAllPost(int currentPage) throws SQLException,ClassNotFoundException{
try{
ResultSet rs=pl.pageList(5,"userinfo",currentPage,"desc","id");(39)
System.out.println(rs);
rs.beforeFirst();
List<Post> list=new ArrayList<Post>();

while(rs.next()){
Post u=new Post();
u.setId(rs.getInt("id"));
u.setTitle(rs.getString("title"));
u.setContent(rs.getString("content"));
u.setTime(rs.getString("time"));

list.add(u);
}
return list;

}catch(Exception e){
e.printStackTrace();
}


com.tchManage.servlet.PostController.java
//查找所有公告
private void findAll(HttpServletRequest request,
HttpServletResponse response) {
try{
//request.setAttribute("pageinfo",postdao.pageSize());
//String currpage=request.getParameter("currentPage");

int currentPage=1;
//if(currpage!=null){
// currentPage=Integer.parseInt(currpage);
//}
List<Post> list = new ArrayList<Post>();
list = postdao.findAllPost(currentPage);
request.setAttribute("findAll", list);
RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
rd.forward(request, response);

}catch(Exception e){
e.printStackTrace();
}

}



PageList.java pageList()分页方法
public ResultSet pageList(int pagesize, String tablename, int currentePage,
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Sat May 26 06:24:28 CST 2018
  • 最近登录:Sat May 26 06:24:28 CST 2018
  • 最近登录:Sat May 26 06:24:28 CST 2018
  • 最近登录:Sat May 26 06:24:28 CST 2018
  • 最近登录:Sat May 26 06:24:28 CST 2018