标签:des style http ar io color os sp for
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package
my.mvc; import
java.io.IOException; import
javax.servlet.Filter; import
javax.servlet.FilterChain; import
javax.servlet.FilterConfig; import
javax.servlet.ServletContext; import
javax.servlet.ServletException; import
javax.servlet.ServletRequest; import
javax.servlet.ServletResponse; import
javax.servlet.http.HttpServletRequest; import
javax.servlet.http.HttpServletResponse; import
my.db.DBManager; /** *
全局过滤器 *
@author Winter Lau *
@date 2010-1-13 下午08:36:18 */ public
class
ControllerFilter implements
Filter { private
ServletContext context; /** *
过滤器初始化 */ public
void
init(FilterConfig cfg) throws
ServletException { this .context
= cfg.getServletContext(); } /** *
执行过滤操作 */ public
void
doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws
IOException, ServletException { HttpServletRequest
request = (HttpServletRequest)req; HttpServletResponse
response = (HttpServletResponse)res; RequestContext
rc = RequestContext.begin( this .context,
request, response); if (rc.uri().indexOf( "/.svn/" )>= 0 ){ rc.forbidden(); return
; } try { chain.doFilter(rc.request(),
rc.response()); } finally { if (rc!= null )
rc.end(); DBManager.closeConnection(); } } /** *
过滤器释放资源 */ public
void
destroy() { } } |
标签:des style http ar io color os sp for
原文地址:http://blog.csdn.net/u014311051/article/details/41984527