异常信息:
Caused by: java.lang.NullPointerException
at qi.javaweb.authority.UserDao.update(UserDao.java:55)
at qi.javaweb.authority.AuthoritySerlvet.updateAuthority(AuthoritySerlvet.java:65)
... 27 more
相关代码:
public void updateAuthority(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String username = request.getParameter("username"); String[] urls = request.getParameterValues("authority"); List<Authority> authorities = dao.getAuthorities(urls); dao.update(username, authorities); response.sendRedirect(request.getContextPath() + "/authority/authority-manager.jsp"); }
public void update(String username, List<Authority> authorities){ users.get(username).setAuthorities(authorities); }
第一段代码中调用第二段代码的方法,从表单中接收username的值,并且接收到了,第二段代码中users是一个Map集合,username作为集合的key,却报了空指针。。。。
users中的数据都打印出来,应该是没有username对应的数据的
打出来了,有数据
应该是dao报的错,dao没有实例化
空指针这种异常很好解决不需要问吧