当我在.get()方法中放置一个属性时,我似乎正在收到一个nullpointer异常,当我调用它的entiire集合时,它打印出我想要的代码。如果有人可以帮助它将非常感谢我新的堆栈溢出。
session.setAttribute("AvailableLessons",availableLessons.getLessons()); will print out contents of the hashmaps.
session.setAttribute("AvailableLessons",availableLessons.getLessons(Lesson.description)); will return null pointer expcetion and the property is a db column name and when i step through it, will have a value in the property.
这是代码的其余部分:
private LessonTimetable availableLessons = new LessonTimeTable();
HttpSession session = request.getSession();
session.setAttribute("Username", username);
response.sendRedirect("/coursework/LessonTimetableView.jspx");
String printOut = ((String) session.getAttribute("Username"));
out.print("You are logged in as " + printOut);
session.setAttribute("AvailableLessons",availableLessons.getDescription());
这是堆栈跟踪:
java.lang.NullPointerException
controller.Controller.processRequest(Controller.java:79)
controller.Controller.doPost(Controller.java:88)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)