ServletConfig对象
servlet配置了初始化参数后,web容器在创建servlet实例对象时,会自动将这些初始化参数封装到ServletConfig对象中,并在调用servlet的init方法时,将ServletConfig对象传递给servlet
<servlet>
<servlet-name></servlet-name>
<servlet-class></servlet-class>
<init-param>
<param-name></param-name>
<param-value></param-value>
</init-param>
</servlet>
TIPS:
在实际开发中 直接可以通过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. |
默默的在进步的程序员