jquery - Spring Security Ajax Custom Filter -


below sample code handling ajaxtimeoutredirectfilter. using spring-security spring framework correctly.

private int customsessionexpirederrorcode = 901; if(authenticationtrustresolver.isanonymous(securitycontextholder.getcontext().getauthentication())) {     logger.info("user session expired or not logged in yet");     string ajaxheader = ((httpservletrequest) request).getheader("x-requested-with");      if ("xmlhttprequest".equals(ajaxheader))     {         logger.info("ajax call detected, send {} error code");         httpservletresponse resp = (httpservletresponse) response;                                    resp.senderror(this.customsessionexpirederrorcode);     }     else     {         logger.info("redirect login page");         throw ase;     } } else {     throw ase; } 

at ui level, trying capture 901 error code on header.jsp globally.

$.ajax({   statuscode: {     400: function() {       alert('400 status code! user error');     },     901: function() {       alert('error 901');     }   } }); 

at browser console can see 901 ok


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -