ajax 调用另一个 url 重置 JsessionId 因此无法继续处理其他链接

ajax call to another url reset JsessionId hence cannot proceed with other links

本文关键字:继续 处理 链接 其他 另一个 调用 url 重置 JsessionId ajax      更新时间:2023-09-26

我通过 call() jquery.ajax调用 restAPI 一旦完成,我就无法使用我的其他 ajax 调用,因此我被抛弃了spring security。 我注意到在完成 restAPI 调用后JsessionID变化(我为 Fire Fox 使用了 httpFox 插件)。 因此,在其余API调用之后我正在做什么,我将通过spring security重定向到登录页面。 我注意到我没有授权用户了。我想如果我能保留最初的"jsessionID"并通过我的浏览器使用它,那就没问题了。谁能给我一些指导我该怎么做?提前谢谢。

这是我对其余 API 的代码

        jQuery.ajax({
        type: "POST",
        //contentType: "application/json; charset=utf-8",
        url: restUrl,
        data: "{}",
        dataType: "json",
        success: function(msg) {
                // load grids
                try{
                    loadBaseGrid(); //this is a jqgrid
                    //will trigger once ajax call is success. but this 
                    //will not complete successfully. becouse of the jsession ID change
                }catch(e){
                    trace('Error in loadBaseGrid -'+e);
                }
            },
        beforeSend : function(req) {
                //req.setRequestHeader("Access-Control-Allow-Origin", "*");
                //req.setRequestHeader('Authorization', token);
                },
        error:function (xhr, ajaxOptions, thrownError){
                    var res = xhr.responseText;
                    try{
                        //var err = JSON.parseWithDate(res);
                        trace(err);
                    }catch(e){
                        trace('Error ->'+e);
                    }
                }    
    });

尝试在 jquery 中的 rest url 上附加 JSESSIONID=?

所以:

url: restUrl="JSESSIONID=YOUR SESSION ID",