青策 2017-06-09 02:04 采纳率: 100%
浏览 1229
已采纳

java,请求出现空指针异常

控制台异常显示

1681496916525609________________1571436348402060
2017-6-9 9:43:07 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet riss2 threw exception
java.lang.NullPointerException
at cn.com.adtech.riss2.controller.platform.paper.PaperManagerController.metaform(PaperManagerController.java:224)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:473)
at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:410)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
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)
at cn.com.adtech.riss2.filter.jiaMiGouFilter.doFilter(jiaMiGouFilter.java:39)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at cn.com.adtech.riss2.filter.PaperLoginCheckFilter.doFilter(PaperLoginCheckFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
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:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)

Java代码

/ String deptOption = departementService.getDepartmentHtmlOption(ToolUnit.NullTo0(paper.getPpinPdepId()));
String degreeOption = degreeService.getDegreeHtmlOption(ToolUnit.NullTo0(paper.getPpinPdegId()));
//String subjectOption = resourceService.getSubjectOptions(ToolUnit.NullTo0(paper.getPpinRstyId()), 0L, "1");
String subjectOption = resourceService.getSubjectHtmlOption(0);
Long teacherId = paper.getPpinSmanId();
System.out.println(teacherId+"________________"+paper.getPpinPdepId());
Long selectId = paper.getPpinPdepId();
//这一行报错
String teacherOption = teacherServce.getTeacherOption(selectId,teacherId);

    request.setAttribute("teacherOption", teacherOption);

// request.setAttribute("deptOption", deptOption);
request.setAttribute("degreeOption", degreeOption);
request.setAttribute("subjectOption", subjectOption);

    session.setAttribute("paper", paper);
    request.setAttribute("submitStep", 2);
    return new ModelAndView("/platform/paper/updateMetaform");
}

数据执行

/**
* 根据院系id获取审核导师html的select下拉列表
* @param 院系id
* @param 若修改中导师已存在,则将该导师改为选中状态
* @return
*/
@Override
public String getTeacherOption(long selectId,long teacherId) {
String hql = "from SysManager sman where sman.smanType=" + SysManager.SMANTYPE_TEACHER +" and sman.smanDeptId="+selectId+ " order by sman.smanName asc";
List list = getHibernateTemplate().find(hql);
if(list == null || list.size() < 1){
return "";
}
System.out.println(teacherId+"_____________________");
StringBuffer buffer = new StringBuffer("");
SysManager sman = null;
for(int i=0,s=list.size(); i < s; i++){
sman = list.get(i);
if (teacherId > 0L && sman.getSmanId()==teacherId) {
buffer.append("< option value='"+sman.getSmanId()+"' selected='selected' > "+sman.getSmanName()+" < /option > ");
continue;
}
buffer.append("< option value='"+sman.getSmanId()+"' > "+sman.getSmanName()+"< /option >");
}
String jsondata = buffer.toString();
list = null;
buffer = null;
return jsondata;
}

说明

这个方法有两次调用,第一次做属于新增页面有一个选择导师的下拉列表,修改页面同样有,主要是为了获取列表,XML也是 配置了的,新增时能够进去,说明没有问题,修改进的是同一个方法结果报错,数据已展示,说明不是数据问题,在方法内打断点没反应,说明没有进,所以猜测是否因为(OncePerRequestFilter.java:76)没有配置字符集,求大神解决

  • 写回答

2条回答 默认 最新

  • sinat_38913556 2017-06-09 02:07
    关注

    SysManager sman = null;
    for(int i=0,s=list.size(); i sman = list.get(i);
    看着不对劲呢

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 根据以下文字信息,做EA模型图
  • ¥15 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热
  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥60 关机时蓝屏并显示KMODE_EXCEPTION_NOT_HANDLED,怎么修?
  • ¥66 如何制作支付宝扫码跳转到发红包界面