֮?*͹

ڣ2021-12-01 14:02:29



Ŀ¼
һFilter1ʲôFilterý2Filter API3FilterFilter
**



һFilter
1ʲôFilterý

1
Servlet淶 Servlet Listener Filter˳ΪL F S
Filtersun˾servlet2.3ӵһ¹ܣjavaEEжһӿ javax.servlet.Filter


2
ͨFilterطwebԴӦ.
WEBԱͨFilterwebwebԴJsp, Servlet, ̬ͼƬļ̬ html ļȽأӶʵһЩĹܡʵURLȨ޷ʿơдʻ㡢ѹӦϢһЩ߼ܡ


3
java webУԴrequest,responseǰ˵һЩϢǰһЩȻٴservletҵ߼˵Ƿurllogin.doĵַûûе½˵,ڴservlet strutsactionǰͳһַȥһЩǷַ


2Filter API

Filterjavax.servletµһӿҪ


destory()doFilter(ServletRequest request,ServletResponse response,FilterCjain chain)init(FilterConfig filterConfig)
3FilterFilter

1Filter
FilterͬһԴأôڿʼFilterִchain.doFilter(request,response)ʱǷһFilter,ֱһFilterִʱûFilter,ŻwebԴ


2ڶFIlterķ˳
жFilterγFilterôǵִ˳ȷģ
ǵִ˳ȡweb.xmlļõȺ˳


3Filter
ᴴFilter󣬲initֻһ.
Դ·Filter·ƥ䣬ִFilterеdoFilter
زķ.
رʱFilterdestroyٲ
JavaEE׼úصķʽС֮󣬻δServlet֮ǰԤظǰ֮кڴ


*

*springģspringֵ֧


java*Ƕ̬ActionõĶṩһֻƿʹ߿ԶһactionִеǰִеĴ룬ҲһactionִǰִֹУͬʱҲṩһֿȡactionпòֵķʽ


AOPAspect-Oriented Programming*ijֶα֮ǰأȻ֮ǰ֮ijЩ


綯̬*ļʵ֣÷ǰӡַҵ߼IJҲ÷ӡַ׳쳣ʱҵ߼IJ


*

*ǻjavaķƵģǻںص
*servletservlet
*ֻܶactionãԶԼеá
*ԷactionġֵջĶ󣬶ܷʡ
actionУ*ԶαãֻʼʱһΡ
*ԻȡIOCеĸbeanͲУҪ*עһserviceԵҵ߼*Իȡiocеservice beanʵҵ߼


ΣصһָͨõĺѺָ루ַΪݸһָ뱻ָĺʱǾ˵ǻصصɸúʵֱַӵãض¼ʱһõģڶԸ¼Ӧ


ΣSpring MVCÿпԶ,ǰΪAction

Ƽ