在做一个使用SSH的项目,在DAO层继承了MappingDispatchAction的类:this.getServlet().getServletContext().removeAttribute("goodlist"),想先把原来放在ServletContext里的goodlist给清除了,再this.getServlet().getServletContext.setAttribute("goodlist",goodlist)做更新。可是页面点击更新后报空指针异常,让我很纳闷。排错后发现是this.getServlet()的到的ActionServlet为空?请问大家是什么原因?顺带问一下,更新ServletContext中的数据是这么做的吗,还有什么其他什么好办法?我之前存放在Session里的一个对象在数据库中做了跟新后也没给session里的对象做更新,可是页面读出来的数据和数据库是同步的,真是越弄越糊涂了,希望能多指教,先谢谢了!