gpt4 book ai didi

java - sessionCookiePath 属性在我的 tomcat7 服务器上不起作用

转载 作者:行者123 更新时间:2023-11-28 23:38:35 24 4
gpt4 key购买 nike

我在我的 tomcat 服务器上部署了两个 Web 应用程序,我希望它们可以相互共享 session 数据。所以我将属性 sessionCookiePath="/"添加到 context.xml 文件中的 Context 标记中。但是重启服务器后,它仍然设置了带有应用程序路径的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"/>

之后,我试图通过applicatoin中的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>

最佳答案

我明白了。

我使用 shiro 管理 session 信息而不是 tomcat 本身,因此省略了“sessionCookiePath”属性。这个应该在shiro.ini里面设置,比如:

sessionIdCookie=org.apache.shiro.web.servlet.SimpleCookie
sessionIdCookie.name=sid
sessionIdCookie.path=/

关于java - sessionCookiePath 属性在我的 tomcat7 服务器上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22341223/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com