【发布时间】:2014-04-15 23:30:45
【问题描述】:
我在我的 tomcat 服务器上部署了两个 web 应用程序,我希望它们可以相互共享会话数据。所以我在 context.xml 文件的 Context 标签中添加了一个属性 sessionCookiePath="/" 。但是重启服务器后,还是设置了应用路径的cookie,比如“Set-Cookie: JSESSIONID=7200fce5-8aee-4d95-b4d8-4ab586dba152; Path=/webapp1; HttpOnly”!
tomcat服务器版本为7.047。
这是我的 context.xml 的内容
<Context sessionCookiePath="/"><WatchedResource>WEB-INF/web.xml</WatchedResource></Context>
这里是 server.xml
<Server port="8005" shutdown="SHUTDOWN"><Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
之后,我尝试在应用程序中使用 web.xml 解决这个问题,添加了 cookie-config 标签,但它仍然不起作用。
这是 web.xml
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>imeapcore</display-name><session-config>
<cookie-config>
<path>/</path>
</cookie-config></session-config>
<listener>
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
</listener>
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>nutz</filter-name>
<filter-class>org.nutz.mvc.NutFilter</filter-class>
<init-param>
<param-name>modules</param-name>
<param-value>com.imeap.webservice.MainModule</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>nutz</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
【问题讨论】:
标签: java session tomcat cookies config