Struts2:会话问题(反向代理后)
我将会话参数存储在使用 SessionAware 接口在操作中获取的 Struts2 会话映射中。我的应用程序位于 /MyApp 路径中。
在 Apache 服务器上设置 struts2 应用程序后,使用反向代理重定向使 URL http://www .appdomain.com/ 指向我在 localhost:8080/MyApp 上的本地 tomcat,Struts2 会话处理不再起作用。我希望会话 cookie 存储为 http://localhost:8080/MyApp 的 Struts2 上下文,而不是http://www.appdomain.com/ ...
Struts2配置中有解决方案吗?或者以某种方式以编程方式更改会话 cookie?在互联网或官方文档中找不到有关此内容的任何信息。请帮忙,我已经在生产中,但我的登录不起作用;-)
I store session parameters in a Struts2 session map that I get in my actions using the SessionAware interface. My Application is in the /MyApp path.
After setting up the struts2 application on an Apache server with an inverse proxy redirect that makes the URL http://www.appdomain.com/ point to my local tomcat on localhost:8080/MyApp, Struts2 session handling doesn't work anymore. I expect that the session cookies are stored for the Struts2 context of http://localhost:8080/MyApp instead of http://www.appdomain.com/ ...
Is there a solution in Struts2 configuration? Or in programmatically changing the session cookie somehow? Couldn't find any info about this on the interwebs or in the official documentation. Please help, I'm already in production and my logins don't work ;-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是旧的,但我发现了它,并且想花 5 美分。
您可以使用的一种修复方法是编辑 web.xml 并在会话配置中设置如下内容:
这会将
希望这可以帮助其他人。
This is old but I found it and would like to drop my 5 cents.
One fix that you can use is to edit the web.xml and in the session-config set something like:
This changes
Hope this may help others.
我刚刚用一个肮脏的黑客解决了这个问题:我将会话 ID 传递给 JSP 并使用 JavaScript 来设置所需的 JSESSIONID cookie 客户端。
函数 createCookie(名称、值、天数) {
如果(天){
var date = new Date();
date.setTime(date.getTime()+(天*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
否则 var 过期 = "";
document.cookie = name+"="+value+expires+"; path=/";
}
$(文档).ready(函数() {
createCookie("JSESSIONID","",3);
});
从这个页面获取JS代码:http://www.quirksmode.org/js/cookies。 html
谢谢,问题解决了!
此致,
蒂姆
I just solved the problem with a dirty hack: I passed the Session Id to the JSP and use a javascript to set the needed JSESSIONID cookie clientside.
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
$(document).ready(function() {
createCookie("JSESSIONID","",3);
});
Got the JS code from this page: http://www.quirksmode.org/js/cookies.html
Thank you, problem solved!
Best Regards,
Tim
将其放入您的
httpd.conf
http:// /httpd.apache.org/docs/current/mod/mod_proxy.html#proxypassreversecookiepath
Put this in your
httpd.conf
http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypassreversecookiepath