ServletConfig 接口和ServletContext 接口
来源:互联网 发布:淘宝招牌图片尺寸 编辑:程序博客网 时间:2024/05/01 17:28
public interface ServletConfig{
在servlet初始化时,容器传递进来一个ServletConfig对象并保存在servlet实例中,可以使用 getServletConfig()得到这个对象,该对象允许访问两项内容:初始化参数和ServletContext对象。
GenericServlet类 作为一个模板类提供默认实现, GenericServlet类的getInitParameter()方法实现就是this.getServletConfig().getInitParameter()。(这里的方法是你的Servlet类继承的来自GenericServlet的方法,可以写出getInitParameter()的样子,也可以直接用getServletConfig().getInitParameter(),也可以用this.getServletConfig().getInitParameter())。
一个servlet可以使用getServletContext()方法得到web应用的servletContext,进而使用getServletContext的一些方法来获得一些值。比如说getServletContext().getRealPath("/")来获得系统绝对路径,getServletContext().getResource("WEB-INF/config.xml")来获得xml文件的内容 。
getServletContext().getInitParameter()取得的是 <context-param>配置的参数。
getServletConfig().getInitParameter()取得的是 <servlet> <init-param>配置的参数
- ServletConfig和ServletContext接口
- ServletConfig和ServletContext接口
- ServletConfig 接口和ServletContext 接口
- ServletConfig 接口和ServletContext 接口
- Servlet技术浅析(五)之-----ServletConfig接口和ServletContext接口
- ServletConfig接口
- ServletConfig接口
- ServletConfig接口
- ServletConfig接口
- 【JavaEE】Servlet接口、ServletConfig接口、GenericServlet抽象类、ServletContext接口、HttpServlet类源码及方法
- ServletContext和servletconfig区别
- ServletContext和ServletConfig分析
- ServletContext,ServletConfig和Sesion
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- PyQt之玩转signal(信号)与slot(槽)二:添加自定义槽
- Windows下编译fast rcnn
- FastJson字段解析问题
- 反射判断成员变量是否静态,并获得其静态成员的值
- URI URL URN的区别
- ServletConfig 接口和ServletContext 接口
- iOS可持续化集成: Jenkins + bundler + cocoapods + shenzhen + fastlane + pgyer
- java exception使用的性能影响,用数据说话
- C++空类中的默认函数
- linux添加新用户
- 如何是用servelt写验证码
- 小技巧、小经验
- 在CSDN注册个ID,好好学点编程知识,哈哈~
- Android SDK Manager下载太慢