Java - JSP Servlet app war与基于Spring 4的Angular2 Rest war之间的会话共享

时间:2017-07-24 00:01:48

标签: spring angular rest servlets websphere

我在互联网上找到了很多帖子和链接,但似乎没有任何效果。该应用程序部署在websphere 9.0上。 JDK8 Spring 4.3.9

我无法在两个war应用程序之间共享会话属性(因为已检查的会话ID保持不变)。我们用过

(a)IBMApplicationSession而不是HttpSession

(b)应用程序部署描述符的扩展。这两者似乎都不起作用。

我在IBM WebSphere上的EAR应用程序中部署了两个战争。其中一个战争是一个简单的旧式JSP servlet应用程序,没有任何东西。

从这场战争开始,我们将请求转发到另一个战争申请的index.html页面。第二个应用程序是基于Angular2 Spring 4的应用程序。当我们在角度应用程序上运行'ng build'时会生成index.htm。随着索引页面加载,我们称之为spring MVC Rest控制器。我们正在尝试访问Rest控制器中的应用程序A servlet中的属性集。但是会话属性不在另一边。

我只是在使用 Servlet类中的httpSession.setAttribute("key", "value"); 然后我在做

getServletContext().getContext(anotherContext).getRequestDispatcher(/index.html")

在另一个应用程序中,有几个HandleInterceptors,然后使用app.routing.ts在index.html的负载上调用Spring MVC带注释的RestController

Inside RestController - 我试图使用

取回属性
httpRequest.getAttribute("key")
httpRequest.getSession().getAttribute("key")

要注意该方法是POST Spring RestContoller,并且HttpServletRequestHttpServletResponse以及HttpSession被添加为方法参数。

我已将HttpSeessionListener添加到spring项目中以跟踪会话创建和销毁。使用这个我能够监视在转发请求期间没有创建或销毁新会话,并在Spring MVC带注释的Rest Controller中接收它。

提前感谢您对此的投入..

0 个答案:

没有答案