ServletConfig

ServletConfig

这个接口是专门用来存储web.xml中servlet的配置信息

类图

ServletConfig介绍与使用

  <servlet>
    <servlet-name>miniDispatchServlet</servlet-name>
    <servlet-class>com.minimvc.www.core.v1.MiniDispatchServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>app.properties</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>miniDispatchServlet</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>

以下是这个接口对应的方法:

  1. String getServletName() ,获取servlet在web.xml中配置的name(即miniDispatchServlet);
  2. ServletContext getServletContext() 获取当前web的servletContext对象;
  3. String getInitParameter(String var1) 获取指定名称初始化参数的值(如获取contextConfigLocation对应的值为app.properties);
  4. Enumeration getInitParameterNames() 获取所有初始化参数的值;

相关文章:

  • 2021-11-30
  • 2021-11-30
  • 2021-09-19
  • 2020-05-11
  • 2021-08-05
  • 2021-12-29
  • 2019-05-23
  • 2021-05-19
猜你喜欢
  • 2023-03-08
  • 2021-09-24
  • 2021-11-27
  • 2021-05-22
  • 2022-01-07
  • 2022-01-11
  • 2021-11-20
相关资源
相似解决方案