Rewrite this method, return to the front JSON, return is to be able to return, but how to deal with after returning?
New AuthenticationEntryPoint () {
@ Override
Public void commence (it 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);
}
});
Online said to add a jquery method is as follows:
$. AjaxSetup ({
DataType: 'HTML',
Complete: a function (XHR, status) {
Var flag=XHR. GetResponseHeader (" flag ");
If (flag=='1') {
Window. The top. The location. The href='https://bbs.csdn.net/html/main/login.html';
}
}
});
But it doesn't perform, because haven't login successful, the browser print directly the json content on it
CodePudding user response:
DataType: 'HTML',Return data type change and json
CodePudding user response: