论坛有发帖,能解决问题,两处都给分
http://bbs.csdn.net/topics/391056175?page=1#post-399359885
参考这篇文件,希望能解决你的问题。我看你的request也变了颜色,是不是自己定义了变量?
http://stackoverflow.com/questions/13971099/nullpointerexception-when-setting-attribute
建议你写个Listener类继承ServletRequestAttributeListener监听下这几个事件:
1. public void attributeAdded(ServletContextAttributeEvent scae)
2 public void attributeReplaced(HttpSessionBindingEvent hsbe)
3 public void attributeRmoved(ServletRequestAttributeEvent srae)
看看什么情况下会触发这几个事件然后就应该知道是什么原因造成的了。
你贴代码出来啊,光看几个代码片段是看不出来的。
主要是和roles有关的;
或者你用System.out.print();打印一下不就一清二楚了吗