【问题标题】:WebLogic server losing session between Ajax callsWebLogic 服务器在 Ajax 调用之间丢失会话
【发布时间】:2012-03-07 00:36:52
【问题描述】:

我有一个可以在 Apache Tomcat 上完美运行的 Web 应用程序。但是,当我将它部署到 WebLogic 10.2.3 服务器时,由于会话为空,它会获得 NPE。

该应用程序是在 Win 7 Pro 上运行的 Java 5、jQuery 1.7.1。对服务器的第一个 Ajax GET 导致一些值存储在会话对象中。下一个 Ajax GET 使用这些值 - 因此 NPE 由于空会话。

在 Firebug 中,我看到传递了不同的会话 ID - 为什么?

谁能帮我解决这个问题?

另一条信息。这是一些相关的jQuery:

    $.ajaxSetup ({
    cache: false,
    xhrFields: {
        withCredentials: true
     },
     crossDomain: true
});

和:

    $('#findSites').click(function() {                                // Locate HTML DOM element with ID "somebutton" and assign the following function to its "click" event...
    searchVal = document.getElementById("searchFor").value;
    searchTyp = document.getElementById("searchType").value;
    $.get('SiteSearchServlet', {searchFor: searchVal, searchType: searchTyp}, function(responseJson) { // Execute Ajax GET request on URL of "someservlet" and execute the following function with Ajax response JSON...
...

【问题讨论】:

  • 在 WebLogic 10.3 上,如果您将以下摘录添加到 weblogic.xml,它会起作用:false-descriptor>
  • 感谢您的建议,但我遇到了同样的错误。
  • 你试过用 .ajax 代替 .get 吗?
  • 我认为 GET 只是调用 ajax... 并且做了 ajaxsetup - 你认为 ajax 中的具体选项是什么来解决这个问题?谢谢

标签: java jquery ajax session weblogic


【解决方案1】:

事实证明,将其添加到文档就绪函数解决了问题(即,现在我使用相同的会话,除非超时):

    jQuery.support.cors = true; // force cross-site scripting

希望这对其他人有所帮助。 标记

【讨论】:

    猜你喜欢
    • 2014-03-21
    • 2014-04-18
    • 2016-03-17
    • 2010-09-24
    • 2012-11-28
    • 2019-04-04
    • 1970-01-01
    • 2016-03-28
    • 1970-01-01
    相关资源
    最近更新 更多