我有带注销控制器的mvc spring app,我想通过get方法发送act param时删除一些cookie。但是cookie仍然存在且没有错误/警告,我尝试了很多东西,但没有结果。也许有人遇到同样的问题?
编辑:我认为这不是一个公开的,因为没有spring mvc这个代码工作正常。 SetContentType text / html无法解决问题。function CheckPolicy() {
var policyCheck = new Object();
policyCheck["PolicyNumber"] = // grab Policy Number from page.
policyCheck["PolicyMod"] = // grab Policy Mod from page.
$.ajax({
url: 'NameOfAspxPageWithCheckPolicyMethod.aspx/CheckPolicy',
type: 'POST',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(policyCheck),
success: function (data) {
// I *think* it'd be data.d.Message. When I've done it, I'm returning
// lists so it is data.d[i].Whatever and iterating it in a for loop.
// can use Chrome's Dev Tools (or others) to inspect the data element
// at the next line and see what it contains (which tells you how to grab).
// May be data.Message, not sure, but again, inspect data at this point.
$('#IdOfSpanForlblresult').text(data.d.Message);
},
error: function (response) {
// probably a similar thing, but you will want to communicate
// how that it failed on the server end somehow. Possibly:
// $('#IdOfSpanForlblresult').text(response.responseJSON.Message);
}
});
}
因此,在经过大量测试后,我发现/ admin / logout设置了另一个具有相同名称且正确MaxAge = 0的cookie,这是不可预期的行为。
我在simple / admin?act = logout
上更改/ admin / logout映射时解决了这个问题