Filter(过滤器)学习

来源:互联网 发布:在线网络北京时间 编辑:程序博客网 时间:2024/05/02 04:33

Filter简介

Filter也称之为过滤器,它是Servlet技术中最激动人心的技术,WEB开发人员通过Filter技术,对web服务器管理的所有web资源:例如Jsp,Servlet,静态图片文件或静态html文件等进行拦截,从而实现一些特殊的功能。例如实现URL级别的权限访问控制、过滤敏感词汇、压缩响应信息等一些高级功能。 
Servlet API中提供了一个Filter接口,开发web应用时,如果编写的Java类实现了这个接口,则把这个java类称之为过滤器Filter。通过Filter技术,开发人员可以实现用户在访问某个目标资源之前,对访问的请求和响应进行拦截,如下所示: 
这里写图片描述

Filter是如何实现拦截的?

Filter接口中有一个doFilter方法,当我们编写好Filter,并配置对哪个web资源进行拦截后,WEB服务器每次在调用web资源的service方法之前,都会先调用一下filter的doFilter方法,因此,在该方法内编写代码可达到如下目的:

  • 调用目标资源之前,让一段代码执行。
  • 是否调用目标资源(即是否让用户访问web资源) 
    web服务器在调用doFilter方法时,会传递一个filterChain对象进来,filterChain对象是filter接口中最重要的一个对象,它也提供了一个doFilter方法,开发人员可以根据需求决定是否调用此方法,调用该方法,则web服务器就会调用web资源的service方法,即web资源就会被访问,否则web资源不会被访问。
  • 调用目标资源之后,让一段代码执行。

Filter开发入门

Filter开发步骤

Filter开发分为二个步骤:

  • 编写java类实现Filter接口,并实现其doFilter方法。
  • 在web.xml文件中使用<filter><filter-mapping>元素对编写的filter类进行注册,并设置它所能拦截的资源。

过滤器范例:

public class FilterTest1 implements Filter {    @Override    public void init(FilterConfig filterConfig) throws ServletException {    }    @Override    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)            throws IOException, ServletException {        System.out.println("FilterTest1执行之前!!!");        // 拦截下目标资源,然后放行(目标资源也会执行)        chain.doFilter(request, response); // 放行        System.out.println("FilterTest1执行之后!!!");    }    @Override    public void destroy() {    }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

在web.xml中配置过滤器:

<!--配置过滤器--><filter>    <filter-name>FilterTest1</filter-name>    <filter-class> cn.itcast.web.filter.FilterTest1</filter-class></filter><!--映射过滤器--><filter-mapping>    <filter-name>FilterTest1</filter-name>    <!-- “/index.jsp”表示拦截对index.jsp页面的请求 -->    <url-pattern>/index.jsp</url-pattern></filter-mapping>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

代表网站首页的index.jsp的代码:

<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body>    <%        System.out.println("index!!!");    %></body></html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

在浏览器输入地址http://localhost:8080/day19/index.jsp访问服务器,Eclipse的控制台打印如下: 
这里写图片描述

在这里总结一下filter在开发中的常见应用

  1. filter在目标资源执行之前,进行权限检查,检查用户有无权限,如有权限则放行,如没有,则拒绝访问。
  2. filter可以在放行之前,对request和response进行预处理,从而实现一些全局性的设置。如:

    public class FilterTest1 implements Filter {    @Override    public void init(FilterConfig filterConfig) throws ServletException {    }    @Override    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)            throws IOException, ServletException {        // 做全局性的设置(对request和response进行一些预处理)        request.setCharacterEncoding("UTF-8");        response.setCharacterEncoding("UTF-8");        response.setContentType("text/html;charset=UTF-8");        System.out.println("FilterTest1执行之前!!!");        // 拦截下目标资源,然后放行(目标资源也会执行)        chain.doFilter(request, response); // 放行        System.out.println("FilterTest1执行之后!!!");    }    @Override    public void destroy() {    }}
    • 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
    • 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
  3. filter可以在放行之后,可以捕获到目标资源的输出,从而对输出做出类似于压缩这样的设置。

Filter链

在一个web应用中,可以开发编写多个Filter,这些Filter组合起来称之为一个Filter链。 
web服务器根据Filter在web.xml文件中的注册顺序,决定先调用哪个Filter,当第一个Filter的doFilter方法被调用时,web服务器会创建一个代表Filter链的FilterChain对象传递给该方法。在doFilter方法中,开发人员如果调用了FilterChain对象的doFilter方法,则web服务器会检查FilterChain对象中是否还有filter,如果有,则调用第2个filter,如果没有,则调用目标资源。也就是说:当调用Filter链对象的doFilter()方法的时候,链对象内部会检查链里面有没有下一个Filter,如果有下一个Filter,那这时会导致下一个Filter执行,如果没有下一个Filter,那这时会导致目标资源执行。 
Filter链范例: 
FilterTest1.java的代码:

public class FilterTest1 implements Filter {    @Override    public void init(FilterConfig filterConfig) throws ServletException {    }    @Override    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)            throws IOException, ServletException {        // 做全局性的设置(对request和response进行一些预处理)        request.setCharacterEncoding("UTF-8");        response.setCharacterEncoding("UTF-8");        response.setContentType("text/html;charset=UTF-8");        System.out.println("FilterTest1执行之前!!!");        // 拦截下目标资源,然后放行(目标资源也会执行)        chain.doFilter(request, response); // 放行        System.out.println("FilterTest1执行之后!!!");    }    @Override    public void destroy() {    }}
  • 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
  • 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

FilterTest2.java的代码:

public class FilterTest2 implements Filter {    @Override    public void init(FilterConfig filterConfig) throws ServletException {    }    @Override    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)            throws IOException, ServletException {        System.out.println("FilterTest2执行之前!!!");        // 拦截下目标资源,然后放行(目标资源也会执行)        chain.doFilter(request, response); // 放行        System.out.println("FilterTest2执行之后!!!");    }    @Override    public void destroy() {    }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

在web.xml中配置过滤器,注意:Filter在web.xml文件中是有注册顺序。 
我们可能这样配置,说实话我们经常这么做不是吗?

<filter>    <filter-name>FilterTest1</filter-name>    <filter-class>cn.itcast.web.filter.FilterTest1</filter-class></filter><filter-mapping>    <filter-name>FilterTest1</filter-name>     <!--“/*”表示拦截所有的请求 -->    <url-pattern>/*</url-pattern></filter-mapping><filter>    <filter-name>FilterTest2</filter-name>    <filter-class>cn.itcast.web.filter.FilterTest2</filter-class></filter><filter-mapping>    <filter-name>FilterTest2</filter-name>     <!--“/*”表示拦截所有的请求 -->    <url-pattern>/*</url-pattern></filter-mapping>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

从以上配置中,关于Filter在web.xml文件中的注册顺序我们是一目了然的,即FilterTest1过滤器在前,FilterTest2过滤器在后。但我们有时候又会这样配置:

<filter>    <filter-name>FilterTest1</filter-name>    <filter-class>cn.itcast.web.filter.FilterTest1</filter-class></filter><filter>    <filter-name>FilterTest2</filter-name>    <filter-class>cn.itcast.web.filter.FilterTest2</filter-class></filter><filter-mapping>    <filter-name>FilterTest1</filter-name>    <url-pattern>/*</url-pattern></filter-mapping><filter-mapping>    <filter-name>FilterTest2</filter-name>    <url-pattern>/*</url-pattern></filter-mapping>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

那这样是不是说只要哪个<filter>标签在前,哪个过滤器就在前呢?可惜并不是这样的,在web.xml中配置的过滤器的先后顺序是依<filter-mapping>的顺序而定。我们只要了解这点就好,没人会闲的蛋疼的考你这方面的知识。
网站首页index.jsp的代码同上。最后在浏览器中输入访问服务器的地址http://localhost:8080/day19/index.jsp,将在Eclipse的控制台打印: 
这里写图片描述

Filter的生命周期

Filter的创建

和我们编写的Servlet程序一样,Filter的创建和销毁由WEB服务器负责。 web应用程序启动时,web服务器将创建Filter的实例对象,并调用其init方法,完成对象的初始化功能,从而为后续的用户请求作好拦截的准备工作。 
注意

  • filter对象只会创建一次,init方法也只会执行一次
  • 开发人员通过init方法的参数,可获得代表当前filter配置信息的FilterConfig对象。

Filter的销毁

destroy方法在Web容器卸载Filter对象之前被调用。该方法在Filter的生命周期中仅执行一次。在这个方法中,可以释放过滤器使用的资源。 
面试题:Filter对象的生命周期。 
答:

  • Filter对象何时被创建? 
    服务器一启动的时候,就会针对这个web应用将所有的Filter对象(拦截器)创建出来,并且以后访问的时候,都是使用同一个拦截器进行拦截。也即一个拦截器会被所有的请求所共享,每一次请求来了之后,都会导致doFilter()方法被调用一次,Filter对象只有一个,而doFilter()方法会被多次调用。 
    问:Filter对象在内存里面有几个? 
    答:一个。服务器并不会针对请求创建新的Filter对象(拦截器)。
  • Filter对象何时被摧毁? 
    移除掉web服务器里面这个web应用(或停掉服务器),就会摧毁这个web应用对应的拦截器。

例,有如下一个过滤器。

public class FilterTest1 implements Filter {    @Override    public void init(FilterConfig filterConfig) throws ServletException {        System.out.println("Filter被创建了!!!");    }    @Override    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)            throws IOException, ServletException {        // 做全局性的设置(对request和response进行一些预处理)        request.setCharacterEncoding("UTF-8");        response.setCharacterEncoding("UTF-8");        response.setContentType("text/html;charset=UTF-8");        System.out.println("FilterTest1执行之前!!!");        // 拦截下目标资源,然后放行(目标资源也会执行)        chain.doFilter(request, response); // 放行        System.out.println("FilterTest1执行之后!!!");    }    @Override    public void destroy() {        System.out.println("Filter被销毁了!!!");    }}
  • 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
  • 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

当启动服务器的时候,Eclipse的控制台会打印Filter被创建了!!!,如下: 
这里写图片描述
当停掉服务器时,Eclipse的控制台会打印Filter被销毁了!!!,如下: 
这里写图片描述

FilterConfig接口

用户在配置filter时,可以使用<init-param>为filter配置一些初始化参数,当web容器实例化Filter对象,调用其init方法时,会把封装了filter初始化参数的filterConfig对象传递进来。因此开发人员在编写filter时,通过filterConfig对象的方法,就可获得:

  • String getFilterName():得到filter的名称。
  • String getInitParameter(String name): 返回在部署描述中指定名称的初始化参数的值。如果不存在返回null。
  • Enumeration getInitParameterNames():返回过滤器的所有初始化参数的名字的枚举集合。
  • public ServletContext getServletContext():返回Servlet上下文对象的引用。

范例:利用FilterConfig得到filter配置信息。

public class FilterTest1 implements Filter {    /*     * Filter对象在被创建时,服务器会调用init()方法,并传递进来这样一个对象:FilterConfig(代表Filter的配置信息)     * FilterConfig对象封装了配置的初始化参数。     */    @Override    public void init(FilterConfig filterConfig) throws ServletException {        System.out.println("Filter被创建了!!!");        String value = filterConfig.getInitParameter("xxx"); // 获取指定初始化参数        System.out.println(value);    }    @Override    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)            throws IOException, ServletException {        // 做全局性的设置(对request和response进行一些预处理)        request.setCharacterEncoding("UTF-8");        response.setCharacterEncoding("UTF-8");        response.setContentType("text/html;charset=UTF-8");        System.out.println("FilterTest1执行之前!!!");        // 拦截下目标资源,然后放行(目标资源也会执行)        chain.doFilter(request, response); // 放行        System.out.println("FilterTest1执行之后!!!");    }    @Override    public void destroy() {        System.out.println("Filter被销毁了!!!");    }}
  • 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
  • 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

在web. xml中配置过滤器:

<filter>    <filter-name>FilterTest1</filter-name>    <filter-class>cn.itcast.web.filter.FilterTest1</filter-class>    <init-param>        <param-name>xxx</param-name>        <param-value>yyyy</param-value>    </init-param></filter><filter-mapping>    <filter-name>FilterTest1</filter-name>    <url-pattern>/*</url-pattern></filter-mapping>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

这样在启动服务器的时候,Eclipse的控制台会打印: 
这里写图片描述
如果我们现在想在FilterTest1类的doFilter方法中使用FilterConfig对象封装的配置初始化参数,那又该怎么做呢?我们可以像下面这样做哟:

public class FilterTest1 implements Filter {    private FilterConfig config;    /*     * Filter对象在被创建时,服务器会调用init()方法,并传递进来这样一个对象:FilterConfig(代表Filter的配置信息)     * FilterConfig对象封装了配置的初始化参数。     */    @Override    public void init(FilterConfig filterConfig) throws ServletException {        System.out.println("Filter被创建了!!!");        // String value = filterConfig.getInitParameter("xxx"); // 获取指定初始化参数        // System.out.println(value);        this.config = filterConfig;    }    @Override    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)            throws IOException, ServletException {        String value = this.config.getInitParameter("xxx");        System.out.println(value);        // 做全局性的设置(对request和response进行一些预处理)        request.setCharacterEncoding("UTF-8");        response.setCharacterEncoding("UTF-8");        response.setContentType("text/html;charset=UTF-8");        System.out.println("FilterTest1执行之前!!!");        // 拦截下目标资源,然后放行(目标资源也会执行)        chain.doFilter(request, response); // 放行        System.out.println("FilterTest1执行之后!!!");    }    @Override    public void destroy() {        System.out.println("Filter被销毁了!!!");    }}
  • 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
  • 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

Filter的部署

Filter的部署分为两个步骤:

  • 注册Filter
  • 映射Filter

注册Filter

开发好Filter之后,需要在web.xml文件中进行注册,这样才能够被web服务器调用。 
在web.xml文件中注册Filter范例:

<filter>    <filter-name>testFitler</filter-name>    <filter-class>org.test.TestFiter</filter-class>    <init-param>        <param-name>word_file</param-name>          <param-value>/WEB-INF/word.txt</param-value>    </init-param></filter>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • <filter-name>用于为过滤器指定一个名字,该元素的内容不能为空。
  • <filter-class>元素用于指定过滤器的完整的限定类名。
  • <init-param>元素用于为过滤器指定初始化参数,它的子元素<param-name>指定参数的名字,<param-value>指定参数的值。在过滤器中,可以使用FilterConfig接口对象来访问初始化参数。如果过滤器不需要指定初始化参数,那么<init-param>元素可以不配置。

映射Filter

在web.xml文件中注册了Filter之后,还要在web.xml文件中映射Filter。

<!--映射过滤器--><filter-mapping>    <filter-name>testFitler</filter-name>    <!--“/*”表示拦截所有的请求 -->    <url-pattern>/*</url-pattern></filter-mapping>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • <filter-mapping>元素用于设置一个Filter所负责拦截的资源。一个Filter拦截的资源可通过两种方式来指定:Servlet名称和资源访问的请求路径。 
    使用Servlet名称来指定Filter拦截的资源,例如:

    <filter-mapping>    <filter-name>CharacterEncodingFilter</filter-name>    <servlet-name>ServletDemo1</servlet-name></filter-mapping>
    • 1
    • 2
    • 3
    • 4
    • 1
    • 2
    • 3
    • 4
  • <filter-name>子元素用于设置filter的注册名称。该值必须是在<filter>元素中声明过的过滤器的名字。
  • <url-pattern>设置filter所拦截的请求路径(过滤器关联的URL样式)。
  • <servlet-name>指定过滤器所拦截的Servlet名称。
  • <dispatcher>指定过滤器所拦截的资源被Servlet容器调用的方式,可以是REQUEST、INCLUDE、FORWARD和ERROR之一,默认REQUEST。用户可以设置多个<dispatcher>子元素用来指定Filter对资源的多种调用方式进行拦截。如下:

    <filter-mapping>    <filter-name>testFilter</filter-name>    <url-pattern>/index.jsp</url-pattern>    <dispatcher>REQUEST</dispatcher>    <dispatcher>FORWARD</dispatcher></filter-mapping>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    <dispatcher>子元素可以设置的值及其意义:

    • REQUEST:当用户直接访问页面时,Web容器将会调用过滤器。如果目标资源是通过RequestDispatcher的include()或forward()方法访问时,那么该过滤器就不会被调用。
    • INCLUDE:如果目标资源是通过RequestDispatcher的include()方法访问时,那么该过滤器将被调用。除此之外,该过滤器不会被调用。
    • FORWARD:如果目标资源是通过RequestDispatcher的forward()方法访问时,那么该过滤器将被调用,除此之外,该过滤器不会被调用。
    • ERROR:如果目标资源是通过声明式异常处理机制调用时,那么该过滤器将被调用。除此之外,过滤器不会被调用。
  • 转自:http://blog.csdn.net/yerenyuan_pku/article/details/52355631
0 0
原创粉丝点击