Home > Back-end >  Taiwan before and after the separation, jump to the login page
Taiwan before and after the separation, jump to the login page

Time:09-21

Spring security Taiwan before and after the separation, jump pavement page, the code is as follows:
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:

reference 1st floor dkwuxiang response:
dataType: 'HTML',

Returns the data type change, json

In the also not line, the key is the js didn't perform, I didn't login, to access a page that security interception and returns a json string to the browser, this process is not a specific page to load the jquery
  • Related