一个关于清空session属性的问题
我想要清空session里的部分属性,但要留住我的登陆信息!代码如下:
Enumeration attNames = session.getAttributeNames(); while ( attNames.hasMoreElements() ) { String attName = (String) attNames.nextElement(); if ( !attName.equalsIgnoreCase( "loginInfo" ) && !attName.equalsIgnoreCase( "VerifyCode" ) && !attName.startsWith( "org.apache" ) ) { session.removeAttribute( attName ); } }
javax.servlet.ServletException: java.util.ConcurrentModificationException at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:520) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:427) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at com.common.baseclass.ActionServletUTF8Encoding.process(ActionServletUTF8Encoding.java:45) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) at javax.servlet.http.HttpServlet.service(HttpServlet.java:114) at javax.servlet.http.HttpServlet.service(HttpServlet.java:91) at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103) at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:192) at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187) at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266) at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:280) at com.caucho.server.port.TcpConnection.handleConnection(TcpConnection.java:563) at com.caucho.server.port.TcpConnection$AcceptTask.doAccept(TcpConnection.java:1122) at com.caucho.server.port.TcpConnection$AcceptTask.run(TcpConnection.java:1069) at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:759) at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:681) at java.lang.Thread.run(Thread.java:619)Caused by: java.util.ConcurrentModificationException at java.util.Hashtable$Enumerator.next(Hashtable.java:1031) at java.util.Collections$1.nextElement(Collections.java:3389) at com.rmdkt.user.advice.SessionAdvice.cleanSessionAttribute(SessionAdvice.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:597) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:576) at org.springframework.aop.aspectj.AspectJMethodBeforeAdvice.before(AspectJMethodBeforeAdvice.java:39) at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:49) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:77) at com.rmdkt.user.advice.LoginValidateAdvice.actionLoginValidate(LoginValidateAdvice.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:597) at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:583) at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:60) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:629) at com.rmdkt.user.company.struts.action.UserMgrShowMyselfEstateBusinessListAction$$EnhancerByCGLIB$$6ac69521.execute(<generated>) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at com.common.baseclass.ActionServletUTF8Encoding.process(ActionServletUTF8Encoding.java:45) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) at javax.servlet.http.HttpServlet.service(HttpServlet.java:114) at javax.servlet.http.HttpServlet.service(HttpServlet.java:91) at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103) at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:192) at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187) at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266) at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:280) at com.caucho.server.port.TcpConnection.handleConnection(TcpConnection.java:563) at com.caucho.server.port.TcpConnection$AcceptTask.doAccept(TcpConnection.java:1122) at com.caucho.server.port.TcpConnection$AcceptTask.run(TcpConnection.java:1069) at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:759) at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:681) at java.lang.Thread.run(Thread.java:619)