config内置对象
  request 是处理用户的请求的对象, response 是处理响应的对象, session 是代表一个用户的对象,主要用于实现登录等操作,
  config 内置对象主要是用来获取配置文件中的初始化参数, config 内置对象的类型是 "javax.servlet.ServletConfig".

Demo: 取得配置文件的初始化参数

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
 1 @SuppressWarnings("serial")
 2 public class EmpServlet extends HttpServlet {
 3     @Override
 4     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 5         this.config(req, resp);
 6     }
 7     public void config(HttpServletRequest req, HttpServletResponse resp) {
 8         //获取config 内置对象
 9         ServletConfig config = super.getServletConfig();
10         //获取初始化参数
11         String initName = config.getInitParameter("name");
12         System.out.println(initName);
13     }
14 }

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄