ServletConfig对象

    servlet配置了初始化参数后,web容器在建立servlet实例对象时,会自动将这些初始化参数封装到ServletConfig对象中,并在调用servlet的init方法时,将ServletConfig对象传递给servlethtml

  <servlet>java

    <servlet-name></servlet-name>web

    <servlet-class></servlet-class>api

    <init-param>this

        <param-name></param-name>spa

        <param-value></param-value>code

    </init-param>htm

  </servlet>对象

TIPS:blog

  在实际开发中 直接能够经过getServletConfig()获得ServletConfig对象

 

String getInitParameter(String name)
Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
Enumeration getInitParameterNames()
Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters.
ServletContext getServletContext()
Returns a reference to the ServletContext in which the caller is executing.
String getServletName() Returns the name of this servlet instance. 
相关文章
相关标签/搜索