getServletConfig() 与getServletContext() 的区别
来源:互联网 发布:英科宇软件输入口令 编辑:程序博客网 时间:2024/05/18 01:55
转自:http://blog.csdn.net/wyd458549392147/article/details/6944470
getServletConfig()
在servlet初始化时,容器传递进来一个ServletConfig对象并保存在servlet实例中,该对象允许访问两项内容:初始化参数和
ServletContext对象,前者通常由容器在文件中指定,
允许在运行时向sevrlet传递有关调度信息,比如说getServletConfig().getInitParameter("debug")后者为servlet提供有关容器的信息。
此方法可以让servlet在任何时候获得该对象及配置信息。
getServletContext()
一个servlet可以使用getServletContext()方法得到web应用的servletContext
即而使用getServletContext的一些方法来获得一些值
比如说getServletContext().getRealPath("/")来获得系统绝对路径
getServletContext().getResource("WEB-INF/config.xml")来获得xml文件的内容
getServletContext()取得的是 <context-param>配置的参数
getServletConfig()取得的是 <servlet> <init-param>配置的参数
2: getServletContext()应用于整个web App,而getServletConfig()仅应用于当前Servlet。 但是ServletConfig对象拥有ServletContext的引用。所以可以通过getServletConfig()来获得web App的
初始值。
- getServletConfig() 与getServletContext() 的区别
- getServletConfig() 与getServletContext() 的区别
- getServletConfig() 与getServletContext() 的区别 .
- getServletConfig() 与getServletContext() 的区别
- getServletConfig() 与getServletContext() 的区别
- getServletConfig() 与getServletContext() 的区别
- getServletConfig() getServletContext() 的区别
- getServletContext和getServletConfig中getInitParameter的区别
- getServletContext和getServletConfig中getInitParameter的区别
- getServletContext和getServletConfig的getInitParameter方法区别
- getServletContext和getServletConfig区别
- getServletConfig()与getServletContext()
- getServletContext和getServletConfig都有getInitParameter的方法 区别
- getServletContext()和getServletConfig()的意思
- getServletContext()和getServletConfig()的意思
- getServletContext()和getServletConfig()的意思
- getServletContext()和getServletConfig()的意思!
- getServletContext()和getServletConfig()的意思
- SSM项目中配置问题
- 模块应用-docopt
- 0000 0001 、HDFS 和 MapReduce
- 大数据批处理框架 Spring Batch全面解析
- JAVA Scanner的用法
- getServletConfig() 与getServletContext() 的区别
- VC6.0 +WDK 开发驱动的环境配置
- mfc groupbox 标题动态修改
- #169. 【UR #11】元旦老人与数列
- angular1 ui-router使用
- 可能用到的java扩展包:javax.*
- 手机打开网站打开出现page not exists错误
- 对齐方式#pragma pack()伪指令及_attribute_aligned_指令
- 编译安装php7