-扩展FormAuthenticationFilter实现动态改变LoginUrl

 

1.修改配置文件

  
        ...  
          
              
                   
              
          
...  
  
  
      

 

2.扩展FormAuthenticationFilter 

public class LZFormAuthenticationFilter extends  FormAuthenticationFilter {
	/**
	 * 重写登录地址
	 */
	protected void redirectToLogin(ServletRequest request,ServletResponse response) throws IOException {
		//request.getLocalAddr()
		HttpServletRequest req=(HttpServletRequest) request;
	String loginUrl = getLoginUrl();
	String url=req.getRequestURI();
	if(url.contains("/mine/")){
		loginUrl="/web/teacher/list.htm";
	}
	WebUtils.issueRedirect(request, response, loginUrl);
	}
}
3. 动态增加shiro的filter地址,可以继承 DefaultFilterChainManager 

			
	/favicon.ico = anon
				/resources/**=anon
				/**/*.jpg = anon

		
 

你可能感兴趣的:(shrio)