【发布时间】:2020-11-19 20:28:14
【问题描述】:
我有一个过滤器:
@WebFilter(urlPatterns = "/Mvc02")
public class Filter02 implements Filter {
public void destroy() {
}
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
some code...
}
public void init(FilterConfig config) throws ServletException {
}
}
还有servlet:
@WebServlet(name = "Mvc02", urlPatterns = "/Mvc02")
public class Mvc02 extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
some code...
}
}
当我进入浏览器并输入 http://localhost:8080/servletjee_war_exploded/Mvc02 时,它会为我提供 servlet。它不应该先给我过滤器吗?如何运行过滤器?
【问题讨论】: