问题日志:
2019-11-21 16:10:53,200:ERROR http-nio-8089-exec-9 (DirectJDKLog.java:175) - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException: null
at com.sgcc.epri.platform.controller.DemandAnalysisController.deleteTBsBLineInfo(DemandAnalysisController.java:152) ~[classes/:?]
原代码:
/**
* 删除
* @param request
* @return
*/
@RequestMapping(value="/deleteTBsBLineInfo")
private ResponseParam deleteTBsBLineInfo(HttpServletRequest request){
String lineId= request.getParameter("lineId")==null?"":request.getParameter("lineId");
// String dataName =DataSourceService.getDataSource();
int j = demandAnalysisService.deleteTBsBLineInfo(lineId,null);
if(j>0){
return new ResponseParam(j);
}
return new ResponseParam("操作失败");
}
错误经历
今天同事遇到了controller层到servise层无法调用的问题一直报参数为空,验证参数确认有值,我先在调用失败的service实现类中定义了一个静态方法直接调用,确认调用没问题并且注解无误,在检查代码时发现定义的方法是private后改为public就能正常调用,我对此疯狂吐槽一定要检查代码的细节。