Login interceptor: ShiroInterceptorFilter . Inherited from FormAuthenticationFilter
Get the request path before being intercepted:
WebUtils.getSavedRequest(request);
String url = savedRequest.getRequestUrl();
public class ShiroInterceptorFilter extends FormAuthenticationFilter { //Default PC-side login request private String loginUrl; //Used to store the request path that needs to be intercepted static List<String> interceptorUrlList = new ArrayList<>(); //Static code block, loading needs to be intercepted [In this example, the request path of the mobile terminal is stored] static{ interceptorUrlList.add("/manage/index"); interceptorUrlList.add("/system"); ...... } //Interceptor The construction method public ShiroInterceptorFilter() { } public ShiroInterceptorFilter(String loginUrl) { this.loginUrl = loginUrl; } //Get/set method of parameters @Override return loginUrl; public String getLoginUrl() { } @Override public void setLoginUrl(String loginUrl) { this.loginUrl = loginUrl; } //Overridden method of jumping to the login page @Override protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException { //From the request header Get the current request path in HttpServletRequest httpServletRequest = (HttpServletRequest) request; String url = httpServletRequest.getServletPath(); //Identification used to determine whether it needs to be intercepted. It does not need to be intercepted by default. Boolean flag = false; //Determine the current Whether the request is a mobile path for (String mobileUrl : interceptorUrlList) { } } if(url.contains(mobileUrl)){ flag = true; //According to the intercepted request, jump to different login request paths if(flag){ //Mobile interface, intercept and jump to mobile login WebUtils.issueRedirect(request, response, "/ddLogin"); } else{ //PC side, jump to PC side to log in WebUtils.issueRedirect(request, response, loginUrl); } } }