什么是“上下文”在“ServletContext”中意思? [英] What does "Context" in "ServletContext" mean?

查看:241
本文介绍了什么是“上下文”在“ServletContext”中意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方法 getServletContextName()返回Web应用程序的名称。这意味着,ServletContext只不过是Web应用程序。好的。

Method getServletContextName() returns the name of the "web application". That means, "ServletContext" is nothing but "web application". Ok.

API定义:


ServletContextListener接收有关更改的通知它们所属的Web应用程序的servlet上下文。

a ServletContextListener receives notifications about changes to the servlet context of the web application they are part of.

Web应用程序的servlet上下文是什么意思?实际上ServletContext中的Context是什么?

What does "servlet context" of the "web application" mean? What actually is "Context" in "ServletContext"?

推荐答案

这个名字确实是IMO,选择非常糟糕。

The name is indeed, IMO, very badly chosen.

我们必须将ServletContext读作基于servlet API的Web应用程序的一般上下文。
我们必须将ServletConfig(另一个标准类)读作servlet的配置。

We must read ServletContext as "the general context of a servlet API based web application". Whereas we must read ServletConfig (another standard class) as "The config of a servlet".

他们应该将IMO命名为ServletContext为WebAppContext或 ApplicationContext,
和ServletConfig asServletContext。

They should IMO have named ServletContext as "WebAppContext" or "ApplicationContext", and ServletConfig as "ServletContext".

BTW,在JSP中,链接到JspPage的范围被命名为page;链接到HttpServletRequest的范围被命名为request;命名为HttpSession的作用域名为session,链接到ServletContext的作用域名为application。

BTW, in JSP, the scope linked to a JspPage is named "page"; the scope linked to a HttpServletRequest is named "request"; the scope named to a HttpSession is named "session", and the scope linked to a ServletContext is named ... "application".

这篇关于什么是“上下文”在“ServletContext”中意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆