有人用过OncePerRequestFilter么???

时间:2022-01-10 18:53:40
听说OncePerRequestFilter只执行一次,但是我用来过滤jsp,每次访问jsp都执行啊,不是说只执行一次吗???


导入spring-web.jar spring-beans.jar spring-core.jar



<filter>
<filter-name>OncePerRequestFilter</filter-name>
<filter-class>filter.TestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OncePerRequestFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>




package filter;

import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.filter.OncePerRequestFilter;

public class TestFilter extends OncePerRequestFilter
{
public void doFilterInternal(HttpServletRequest request,HttpServletResponse response,FilterChain chain)
throws ServletException,IOException
{
System.out.println("begin");
chain.doFilter(request, response);
System.out.println("end");
}
}


2 个解决方案

#1


快掉到第2页了。。顶起。。

#2


靠。。难道真的没人用过么??

#1


快掉到第2页了。。顶起。。

#2


靠。。难道真的没人用过么??