Java课题笔记~ ServletContext

单个Servlet的配置对象

Java课题笔记~ ServletContext_第1张图片

 web.xml


    FirstServlet
    com.ambow.test.FirstServlet
    
        charset
        utf-8
    


    FirstServlet
    /first01

获取单个Servlet的初始化参数

ServletConfig config;

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    this.config = config;
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	String charset = config.getInitParameter("charset");//获取初始化参数
    ...
}

你可能感兴趣的:(Java,java,笔记,开发语言,ServletConfig,servlet)