我有一个可以在 Apache Tomcat 上完美运行的网络应用程序。但是,当我将它部署到 WebLogic 10.2.3 服务器时,由于 session 为空,它得到一个 NPE。
该应用程序是在 Win 7 Pro 上运行的 Java 5、jQuery 1.7.1。对服务器的第一个 Ajax GET 导致一些值存储在 session 对象中。下一个 Ajax GET 使用这些值 - 因此 NPE 由于空 session 。
在 Firebug 中,我看到正在传递不同的 session 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...
...
最佳答案
事实证明,将此添加到文档就绪函数解决了问题(即现在我使用相同的 session ,除非超时):
jQuery.support.cors = true; // force cross-site scripting
希望这对其他人有帮助。 标记
关于java - WebLogic 服务器在 Ajax 调用之间丢失 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9297295/