ServletContext,PageContext,ServletConfig,JSPContext,这些类的关系和区别

2024-10-28 14:45:29
推荐回答(2个)
回答1:

pageContext跟servletContext的区别是有的,呵呵 它们是域对象
你去看看api吧

pageContext是用在jsp中,主要是用到标签类中,PageContext extends JspContext to provide useful context information for when JSP technology is used in a Servlet environment

而ServletContext则是servlet中使用,它只是一个接口。Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file。
The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized

回答2:

以下这四个参数甲乙说明:
ServletContext是容器上下文
PageContext是页面内置对象,所有的操作范围是页面内
servletConfig是全局配置参数,在整个容器有效
jspContext是在jsp范围有效。