参考网址:
上下文对象》监听》过滤器》servlet
1.先加载上下文对象
<!-- 初始化Spring classpath*:spring/applicationContext-*.xml, --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:applicationContext_*.xml </param-value> </context-param>
2.加载监听
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
3.加载filter 链
完整的Filter流程是:Filter对用户请求进行预处理,接着将请求交给Servlet进行处理并生成响应,最后Filter再对服务器响应进行后处理。
<filter> <filter-name>loginFilter</filter-name> <filter-class>com.test.filter.loginFilter</filter-class> </filter> <!--filter-mapping 要写在filter之后--> <filter-mapping> <filter-name>loginFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>