首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Servlet中 getServletConfig() 与 getServletContext() 的差异

2013-11-13 
Servlet中 getServletConfig() 与 getServletContext() 的区别getServletContext() 是获取web.xml中 cont

Servlet中 getServletConfig() 与 getServletContext() 的区别
getServletContext() 是获取web.xml中 <context-param> 配置的参数

getServletConfig() 是获取web.xml 中 <servlet>中<init-param> 配置的参数

ServletConfig对象拥有对ServletContext对象的引用,所以可以通过
getServletConfig().getServletContext()来获取ServletContext对象

ServletContext对象应用于整个web app,而ServletContext只应用于当前Servlet

热点排行