1、获得 servlet配置的servletname

2、获得servlet 配置的  getInitParameter(“keyname”)

3、获得servlet配置的 所有的 key

package cn.jiemoxiaodi.servlet_config;

import java.io.IOException;
import java.util.Enumeration; import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; public class BServlet implements Servlet { private ServletConfig config; public void destroy() { } public ServletConfig getServletConfig() {
return this.config;
} public String getServletInfo() {
return null;
} public void init(ServletConfig config) throws ServletException {
this.config = config;
} public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
// 1\
// System.out.println(this.config.getServletName()+"==="+this.config.getInitParameterNames());
// 2\ System.out.println(this.config.getInitParameter("a"));
// 3\Enumeration em = this.config.getInitParameterNames();
// while (em.hasMoreElements()) {
// String key = (String) em.nextElement();
// System.out.println(key);
// }
// 4\ServletContext sc= this.config.getServletContext(); } }

ServletConfig 可以做啥的更多相关文章

  1. javaee 导航

    tomcate端口设定和服务器虚拟目录设定 静态web 应用和动态web应用 tomcat相关问题 web应用 http 响应 url uri 动态页面 servlet 一个简单的servlet的de ...

  2. servelt filter listener 的生命周期

    1. servlet    当第一次请求一个servlet资源时,servlet容器创建这个servlet实例,并调用他的 init(ServletConfig config)做一些初始化的工作,然后 ...

  3. JavaWeb学习之Servlet(四)----ServletConfig获取配置信息、ServletContext的应用

    [声明] 欢迎转载,但请保留文章原始出处→_→ 文章来源:http://www.cnblogs.com/smyhvae/p/4140877.html [正文] 一.ServletConfig:代表当前 ...

  4. JavaWeb之Servlet: ServletConfig 与 ServletContext

    ServletConfig对象 什么是ServletConfig对象 ServletConfig对象,叫Servlet配置对象.主要用于加载配置文件的初始化参数. 创建时机 ServletConfig ...

  5. ServletConfig

    ServletConfig Servlet配置 比如web程序中的某一个Servlet需要配置一些初始化信息,需要在web.xml中进行配置 <servlet> <servlet-n ...

  6. 1、Servlet 2、ServletConfig 3、ServletContext 4、HttpUrlConnection

    1.Servlet 2.ServletConfig 3.ServletContext 4.HttpUrlConnection 07. 五 / J2EE / 没有评论   一.第一个Servlet的编写 ...

  7. Servlet入门和ServletConfig、ServletContext

    Servlet是一门用于开发动态web资源的技术. 若想开发一个动态web资源,需要完成以下2个步骤: 1)编写一个Java类,实现servlet接口: 2)把开发好的Java类部署到web服务器中. ...

  8. Servlet容器模型(四)ServletConfig、ServletContext

    这两天刚刚回顾了一下servlet中的配置对象ServletConfig.上下文对象ServletContext.多线程相关的知识点,做了一下笔记,如下: 一.Servlet配置对象(ServletC ...

  9. Servlet第二篇【Servlet调用图、Servlet细节、ServletConfig、ServletContext】

    Servlet的调用图 前面我们已经学过了Servlet的生命周期了,我们根据Servlet的生命周期画出Servlet的调用图加深理解 Servlet的细节 一个已经注册的Servlet可以被多次映 ...

随机推荐

  1. POJ-1068题

    下面的代码是北京大学Online Judge网站上1068题(网址:http://poj.org/problem?id=1068)的所写的代码. 该题的难点在于实现括号匹配,我在代码中采取用-1和1分 ...

  2. jquery替换所有逗号

    代码: var aa= $("input[name=aa]").val().replace(/\,/g,""); 原文:http://blog.csdn.net ...

  3. 使用MEF实现通用参数设置

    通用后台管理系统必备功能模块包含日志管理,权限管理,数据字典,参数配置等功能.参数设置主要用于设置系统运行所需的一些基础性配置项,比如redis缓存,mq消息队列,系统版本等信息.好的参数设置需要达到 ...

  4. IDEA 和 Eclipse 使用对比

    前段时间从 Eclipse 中将开发工作转移到了 IDEA. IDEA 确实有很多地方比 Eclipse 做的好,总结了一些 IDEA 和 Eclipse 的不同. 1.文件和导航关联 经常需要打开某 ...

  5. VPN使用指南|稳定的VPN|

    之前一直用GoagentFQ,但是有时不太稳定,网速也不是很快,然后就试用了云梯VPN,感觉还不错,网速挺快,也比较稳定.http://opticalvpn.com/?r=72ec52481ab8d2 ...

  6. 招聘前端、Java后端开发、测试、Mysql DBA

    公司介绍: http://www.lagou.com/gongsi/43095.html http://www.yamichu.com 简历发到: zhuye@yamichu.com 招聘职位: JA ...

  7. 利用python合并两个文件

    1格式如下 在做利用zabbix的api来批量添加主机的时候,需要处理ip和hostname,在借用别人写的py程序的基础上,自己有改装了以下脚本,为自己使用.需要时ip和hostname为一个统一格 ...

  8. 更改UIsearchbar 的背景和cancel按钮(转)

    修改背景 searchbar =[[UISearchBar alloc]initWithFrame:CGRectMake(,KTopBarHeight, , KTopBarHeight)]; sear ...

  9. nodejs中exports与module.exports的区别

    转自--http://www.cnblogs.com/pigtail/archive/2013/01/14/2859555.html 你肯定非常熟悉nodejs模块中的exports对象,你可以用它创 ...

  10. 【bzoj4514】 Sdoi2016—数字配对

    http://www.lydsy.com/JudgeOnline/problem.php?id=4514 (题目链接) 题意 n个数,每个数值为a[i],有b[i]个,权值为c[i].若两个数能配对当 ...