我正在开发一个Extjs-6应用程序。我的服务器应用程序是RestFul。我必须用Ajax登录。我发送一个Ajax请求,如下所示:
Ext.Ajax.request({
url: 'localhost:8084/Calk/j_spring_security_check',
params: {j_username: 'ali', j_password: '123456',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: ...,
faiulure: ...,
});
客户收到后200 OK
,将读取商店,如下所示:
Ext.define('Calk.store.Calk', {
extend: '...',
model: '...',
proxy: {
type: 'ajax',
url: 'localhost:8084/Calk/calk/all',
withCredentials: true,
useDefaultXhrHeader: false,
reader: ...,
method: 'POST'
});
为什么cookie设置错误?我该如何解决?
在Ext config中设置以下行:
Ext.Ajax.on("beforerequest",function(con){
con.setUseDefaultXhrHeader(false);
con.setWithCredentials(true);
});
因此,所有的ajax请求都将发送cookie。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句