同一tomcat下不同web项目session共享方法
声明:是一个tomcat下的不同web项目,不是不同tomcat不同项目的,所有这里不会说用什么集群的方法....
???? 其实也很简单,就是将session保存在ServletContext里面就可以了。
?
???? 在项目A中:
?
???session.setAttribute("user",user);
???ServletContext ContextA =session.getServletContext();
???ContextA.setAttribute("session", session);
?
???? 在项目B中:添加一个过滤器(web.xml配置就不写了)
crossContext必须设置为true,否则没用!!!!
?
?
此文为转载