十四、Servlet技术总结


	过滤器技术:
			1.概念
				过滤器是serlet技术,也叫filter。
				它可以对http请求进行拦截。
			2.作用
				他可以实现权限拦截、编码统一处理、过滤无效关键字等,
			3.过滤器的生命周期
				|--- interface  Fileter
							init(FilterConfig  config)
							doFilter(req,resp)
							destory()
							
				1.tomcat服务器启动时,就会初始化filter实例。
				  服务器创建filter实例,然后调用init方法,
				  将web.xml中配置的过滤器配置传入到过滤器中。
				2.用户发送http请求,过滤器进行拦截。
				    过滤器链前置逻辑-->请求资源代码 -->过滤器链的后置落	
					
					
			4.过滤器的相关API
						|--- interface  Fileter 过滤器接口
							init(FilterConfig  config)
							doFilter(req,resp)
							destory()
						
						|--- FilterConfig 通过这个对象,可以获取过滤器在web.xml中配置

						|--- FilterChain  过滤器执行链对象
								 doFilter(req,reso) 对请求资源进行放行,进入到下一个过滤器或执行请求。
			
			5.执行细节
					配置拦截资源
						/* 拦截所有资源
						/index.jsp ;拦截指定资源					 
			6.案例
				    1)编码统一处理
				    2) 登录注册	
			
		监听器技术:
				1,概念
					监听器是监听特定对象的创建、销毁或特定对象的属性的变化。
				
				2.作用
					监听器可以实现在线列表展示、踢人等功能。
				
				3.监听器相关API
					生命周期监听器
							ServletContextListener
							ServletRequetListener
							HttpSessionListener
							
					属性监听器
							ServletContextAttributeListener
							ServletRequetAttributeListener
							HttpSessionAttributeListener
					其他监听器
							HttpSessionBoundListener		

Servlet、ServletContext、ServletConfig、HttpSession、ServletRequest、ServletResponse、Filter、FilterChain、FilterConfig、Listener

发布了113 篇原创文章 · 获赞 0 · 访问量 1283

猜你喜欢

转载自blog.csdn.net/weixin_45602227/article/details/104466806
今日推荐