Struts2:会话问题(反向代理之后) [英] Struts2: Session Problem (after reverse proxy)

查看:144
本文介绍了Struts2:会话问题(反向代理之后)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将会话参数存储在我使用SessionAware接口操作的Struts2会话映射中。我的应用程序位于/ MyApp路径中。

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.

在具有反向代理重定向的Apache服务器上设置struts2应用程序后,使URL http://www.appdomain.com/ 指向 localhost:8080 /上的本地tomcat MyApp ,Struts2会话处理不再起作用。我希望会话cookie存储在 http:// localhost:8080 / MyApp 的Struts2上下文中,而不是 http://www.appdomain.com/ ...

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/ ...

Struts2配置中是否有解决方案?或者以某种方式以编程方式更改会话cookie?在interwebs或官方文档中找不到任何关于此的信息。请帮助,我已经投入生产,登录不起作用; - )

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 ;-)

推荐答案

我刚解决了问题脏黑客:我将会话ID传递给JSP,并使用javascript设置所需的JSESSIONID cookie客户端。

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 = /;
}

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);
});

$(document).ready(function() { createCookie("JSESSIONID","",3); });

从此页面获得JS代码: http://www.quirksmode.org/js/cookies.html

Got the JS code from this page: http://www.quirksmode.org/js/cookies.html

谢谢,问题解决了!

最好的问候,
Tim

Best Regards, Tim

这篇关于Struts2:会话问题(反向代理之后)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆