forbiddenfilter.java
来自「spring+acegi编写的网上书城」· Java 代码 · 共 29 行
JAVA
29 行
package net.livebookstore.web.filter;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
/**
* Provent user access some files (e.g.: *.htm) directly. Any access to these
* resources will cause a 403 Forbidden error.
*
* @author Xuefeng
*/
public class ForbiddenFilter implements Filter {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
// send a 403 error:
((HttpServletResponse)response).sendError(HttpServletResponse.SC_FORBIDDEN);
// after send a 403 error, there is no need to continue the filter chain!
}
public void init(FilterConfig config) throws ServletException {
}
public void destroy() {
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?