码迷,mamicode.com
首页 > 其他好文 > 详细

ServletConfig

时间:2014-11-14 18:02:29      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:request   public   

<servlet>

<servlet-name>Demo</servlet-name>

<servlet-class>com.Demo</servlet-class>

<init-param>

<param-name>xx</param-name>

<param-value>123</param-value>

</init-param>


<init-param>

<param-name>bbb</param-name>

<param-value>111</param-value>

</init-param>

</servlet>


public class Demo extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {


//获取指定的初始化参数

String value = this.getServletConfig().getInitParameter("xxx");

response.getOutputStream().write(value.getBytes());


//获取所有的初始化参数

Enumeration e = this.getServletConfig().getInitParameterNames();

while (e.hasMoreElements()) {

String name = (String) e.nextElement();

value = this.getServletConfig().getInitParameter(name);

response.getOutputStream().write((name + "=" + value + "<br/>").getBytes());

}

}

}


ServletConfig

标签:request   public   

原文地址:http://7948864.blog.51cto.com/7938864/1576563

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!