Ther 是扩展 HttpServlet 并尝试访问在不同类中设置的变量的类
扩展 HttpServlet 的类中的以下代码行抛出 NullPOinterException:
SomeObject x = getServletContext().getAttribute("x");
想法?
可能,你已经覆盖了 Servlet 类中的 init(ServletConfig cfg) 方法,并且没有调用 super.init(cfg) 来执行标准设置,从而导致上下文为空。