qq_33966913
青策
2017-06-09 02:04

java,请求出现空指针异常

20
  • exception
  • 控制台
  • 数据
  • java
  • stringbuffer

控制台异常显示

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条回答