Struts 2 会话值未反映在负载平衡环境/域 URL 中的 JSP 中
我有一个 struts 2 应用程序,其中有一个链接,单击该链接时,它会执行操作类中的一个方法,并将用户重定向到另一个操作类,该操作类最终转发到 JSP 页面。在该 JSP 页面中,我有 3 个 DIV,其中包含了另一组 JSP 页面。这些 JSP 页面正在访问存储在应用程序中的会话值,我的问题是这些会话值没有被显示。会话值就在那里,因为当我点击 REFRESH / F5 按钮时,它们就会正确显示。
并且这种情况仅发生在测试中的负载平衡(域 URL)环境中,当使用单独的服务器 URL 访问应用程序时不会发生这种情况。请任何人帮助我解决这个问题,需要立即解决这个问题。这是我在 struts.xml 中的代码,它负责重定向到另一个操作类:
<action name="newPriceSheet" class="com.customer.catalogui.actions.DisplayCategoryAction" method="showPreviousSelection">
<interceptor-ref name="defaultLoginStack" />
<result name="success" type="redirect">
<param name="location">displayCategory.action</param>
<param name="parse">false</param>
</result>
</action>
I have a struts 2 application, where I have a link and on clicking on that link, it executes a method inside an action class and redirect the user to another action class which eventually forwards to a JSP page. In that JSP page, I have 3 DIVs where I have included another set of JSP pages. These JSP pages are accessing session values stored in the application, my issue is that these session values are not being displayed. the session values are in there because the moment I hit REFRESH / F5 button they are being displayed correctly.
AND this is happening only in my load balanced (domain URL) environment in Test, it is not happening when the application is accessed using individual server URLs. Please anyone help me on this, need to get this addressed right away. Here is the code that I ahve in my struts.xml which takes care of redirecting to another action class:
<action name="newPriceSheet" class="com.customer.catalogui.actions.DisplayCategoryAction" method="showPreviousSelection">
<interceptor-ref name="defaultLoginStack" />
<result name="success" type="redirect">
<param name="location">displayCategory.action</param>
<param name="parse">false</param>
</result>
</action>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此问题与Struts2无关。您需要配置负载均衡器,以便在建立会话后将所有请求路由到同一服务器。这通常称为会话亲和性或粘性会话。
我建议您编辑您的问题,以提供有关您正在使用的负载均衡器以及您用于运行 Java 应用程序的 servlet 容器/应用程序服务器的更多信息。我已经重新标记了您的问题,希望能得到更多的关注。以下是一些可能对您有所帮助的资源:
This issue is not related to Struts2. You need to configure your load balancer to route all requests to the same server when a session has been established. This is typically referred to as session affinity or sticky sessions.
I would advise you to edit your question to provide some more information on what load balancer you are using as well as what servlet container/app server you are using to run your Java application. I've re-tagged your question to hopefully get it some additional exposure. Here are some resources which may help you out: