————项目启动运行成功—————
com.houtai.demo.DemoApplication : Started DemoApplication in 5.638 seconds (JVM running for 8.145)
o.a.c.c.C.[Tomcat].[localhost].[/demo] : Initializing Spring DispatcherServlet 'dispatcherServlet'
o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
o.s.web.servlet.DispatcherServlet : Completed initialization in 11 ms
o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/demo] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException: null
at com.houtai.demo.web.AreaController.getAreaById(AreaController.java:45) ~[classes/:na]
以上为异常信息,java45为Area area = areaService.getAreaById(areaId);上下文没错。异常处理信息errMsg:null
恳请老师和各位同学们帮忙解疑,git clone老师的项目下来运行也是一样的结果。
@RequestMapping(value = "/getareaid",method = RequestMethod.GET) //下面的areaId要和地址栏上面的?areaId相同 areaid不行 应该是Java严格区分大小写的原因 是areaId就是areaId private Map<String,Object> getAreaId(Integer areaId){ Map<String,Object> modelMap=new HashMap<String, Object>(); Area area=areaService.queryAreaById(areaId); modelMap.put("area",area); return modelMap;
getareaid 这个在地址栏上写错了,大小写没有匹配
null值可以debug调试一下看看