赞
踩
public class AuthorVerifyFilter implements Filter { private FilterConfig config; @Override public void init(FilterConfig filterConfig) throws ServletException { this.config = filterConfig; } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; HttpServletResponse httpResponse = (HttpServletResponse) servletResponse; //跳转至首页 if(true){ httpResponse.sendRedirect(httpRequest.getContextPath()+ "/index.action"); return; } filterChain.doFilter(httpRequest,httpResponse); } @Override public void destroy() { this.config = null; } }
<filter>
<filter-name>AuthorVerifyFilter</filter-name>
<filter-class>com.module.filter.AuthorVerifyFilter</filter-class>
<init-param>
<param-name>loginPage</param-name>
<param-value>/login.action</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>AuthorVerifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。