Advertisement

JavaWeb实验五(四),在Servlet中获取应用程序配置参数

阅读量:
在这里插入图片描述

1.该类的代码 代码有注释

注意:

  1. 声明变量initParam
  2. 对init方法进行重构
复制代码
    	public void init(ServletConfig config) throws ServletException {
    		this.initParam = config.getInitParameter("url"); // 读取初始化参数
    	}
    
    
      
      
      
    
  1. 对doGet方法进行重新编写
复制代码
    	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		//System.out.println("初始化参数:" + this.initParam); // 输出初始化参数
    
    		response.setContentTy

全部评论 (0)

还没有任何评论哟~