spring security 前后臺分離,跳轉路面頁面,代碼如下:
重寫這個方法,回傳前端JSON,回傳是能回傳,但是回傳后如何處理?
new AuthenticationEntryPoint(){
@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException aexp) throws IOException, ServletException {
// TODO Auto-generated method stub
JSONObject jo = new JSONObject();
jo.put("flag", "-1");
Util.outJSON(response, jo);
}
});
網上介紹說要在jquery中加個方法如下:
$.ajaxSetup({
dataType: 'html',
complete: function(xhr,status) {
var flag = xhr.getResponseHeader('flag');
if(flag == '-1') {
window.top.location.href = '../../html/main/login.html';
}
}
});
但是這段根本沒執行,因為都沒登錄成功,瀏覽器中直接列印了上面的json內容
uj5u.com熱心網友回復:
dataType: 'html',回傳資料型別換一下,json
uj5u.com熱心網友回復:
換了也不行,關鍵是這段js沒執行,我沒登錄,隨便訪問一個頁面,security截取并回傳一個json字串給瀏覽器,這個程序沒有一個具體頁面加載了jquery
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/59162.html
標籤:Web 開發
上一篇:資料無法打通
