Spring security Sencha Touch 2&;Spring安全跨域登录

Spring security Sencha Touch 2&;Spring安全跨域登录,spring-security,sencha-touch-2,Spring Security,Sencha Touch 2,我需要使用一些服务器的API从Sencha触摸2应用程序。要使用此API,我需要在服务器上进行身份验证 因此,我已经实现了登录功能: Ext.Ajax.request({ url: 'http://192.168.1.2:8080/spring-security-extjs-login/j_spring_security_check', method: 'POST', params: { j_username

我需要使用一些服务器的API从Sencha触摸2应用程序。要使用此API,我需要在服务器上进行身份验证

因此,我已经实现了登录功能:

Ext.Ajax.request({
            url: 'http://192.168.1.2:8080/spring-security-extjs-login/j_spring_security_check',
        method: 'POST',
        params: {
                j_username: 'rod',
                j_password: 'koala',
            },
            withCredentials: false,
            useDefaultXhrHeader: false,

            success: function(response){
                var text = response.responseText;
        Ext.Msg.alert("success", text, Ext.emptyFn);
            },

            failure: function(response){
                var text = response.responseText;
        Ext.Msg.alert('Error', text, Ext.emptyFn);
            }
});
但我如何调用API,因为在身份验证之后,我尝试调用API,但他们已经想要身份验证了。可能我需要保存JSESSIONID并将其添加到另一个请求中,但我不知道如何才能做到这一点

我无法使用withCredentials:true,因此我需要找到另一个解决方案

如何从响应HTTP头获取设置cookie

我在Chrome控制台中看到,JSESSIONID出现在响应头中,所以我需要得到它


请帮助我找到任何解决方案。

您可以使用
requestcomplete
beforerequest
事件分别读取响应头和写入请求头。以下是示例代码:

Ext.Ajax.on('requestcomplete', function(conn, response, options, eOpts){
    var respObj = Ext.JSON.decode(response.responseText);
    Helper.setSessionId(options.headers['JSESSIONID']);
}, this);

Ext.Ajax.on('beforerequest', function(conn, options, eOptions){
    options.headers['JSESSIONID'] = Helper.getSessionId();
}, this);

您好,谢谢您的回答,但我有另一个错误:无法读取未定义的属性“JSSessionID”,但它确实存在于响应标头中,我在浏览器中使用控制台中的dev.toolsdump
options
看到了它,并查看了它的位置