黑马程序员技术交流社区

标题: 这段java程序引发了空指针异常,求解释? [打印本页]

作者: 张超超    时间: 2012-4-19 09:48
标题: 这段java程序引发了空指针异常,求解释?
private void get()
{

List<CustContactMVO> curentResult = new ArrayList<CustContactMVO>();
CustContactMVO m1=new CustContactMVO();
m1.setContactId("001");
curentResult.add(m1);
PagView pagview=new PagView();
pagview.setCount(7);
pagview.setPagCount(3);
pagview.setPagNo(0);
pagview.setPagSize(2);
pagview.setViewList(curentResult);
current.setPagView(pagview);

}
这段程序引发了空指针异常,求解释?

严重: Servlet.service() for servlet DPTW threw exception
java.lang.NullPointerException
at java.lang.StringBuilder.<init>(StringBuilder.java:92)
at com.cattsoft.mscrm.common.struts2.interceptor.RequestExceptionHandler.handle(RequestExceptionHandler.java:51)
at com.cattsoft.mscrm.common.struts2.interceptor.ApplicationMasterFilter.doFilter(ApplicationMasterFilter.java:141)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:619)

作者: liuyang    时间: 2012-4-19 10:13
根据楼主上面的代码看,每个变量都有值啊,你用debug模式跟踪一下,看看
作者: 蒋亮    时间: 2012-4-19 14:08
current.setPagView(pagview);current变量实例化了没?




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2