读书人

Servlet中 getServletConfig() 与 get

发布时间: 2013-11-13 14:04:18 作者: rapoo

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

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

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

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

读书人网 >编程

热点推荐