1.ServletConflg对象的概述
ServletConflg用来获得Servlet的相关的配置对象
获得ServletConflg对象方法(getServletConflg() )
2.ServletConflg对象的API
*获得Servlet的初始化参数
*获得ServletConflg对象
*获得Servlet的名称
```java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ServletConfig servletConfig = this.getServletConfig();
String name = servletConfig.getInitParameter("username");
String password = servletConfig.getInitParameter("password");
System.out.println(name+"....."+password);
Enumeration<String> initParameterNames = servletConfig.getInitParameterNames();
while (initParameterNames.hasMoreElements()) {
String na =initParameterNames.nextElement();
String value = servletConfig.getInitParameter(na);
System.out.println(na+"..."+value);
}
String servletName = servletConfig.getServletName();
System.out.println(servletName);
}`在这里插入代码片`