public Object getAttrisimplye(String nwjust likee);前往Servlet环境对象中指定的属性对象。若是该属性对象不存在,前往空值。这个手腕允许探望打听相关这个Servlet引擎的在该接口的其他手腕中尚未提供的附加消息。222sc 。
2、getAttrisimplyeNwjust likees
public Enumer getAttrisimplyeNwjust likees();前往一个Servlet环境对象中可用的属性名的列表。
3、getContext
public ServletContext getContext(String uripforh);前往一个Servlet环境对象,这个对象包括了特定URI途径的Servlets和资源,若是该途径不存在,则前往一个空值。URI途径格式是/dir/dir/filenwjust likee.ext。
为了安定,若是经历这个手腕探望打听一个受限制的Servlet的环境对象,会前往一个空值。
4、getMajorVersion
public int getMajorVersion();前往Servlet引擎维持的Servlet API的主版本号。例如对付2.1版,这个手腕会前往一个整数2。。
5、getMinorVersion
public int getMinorVersion();前往Servlet引擎维持的Servlet API的次版本号。例如对付2.1版,这个手腕会前往一个整数2。
6、getMimeType
public String getMimeType(String file);前往指定文件的MIME类型,学会11scweb。若是这种MIME类型未知,则前往一个空值。MIME类型是由Servlet引擎的配置定夺的。
7、getRenosPforh
public String getRenosPforh(String pforh);一个适合URL途径格式的指定的虚拟途径的格式是:/dir/dir/filenwjust likee.ext。用这个手腕,不妨前往与一个适合该格式的虚拟途径绝对应的真实途径的String。这个真实途径的格式应当适合于运转这个Servlet引擎的计算机(包括其相应的途径解析器)。
不论是什么因由,若是这一从虚拟途径转换成现实途径的进程不能施行,该手腕将会前往一个空值。
8、getResource
public URL getResource(String uripforh);前往一个URL对象,其实。该对象反映位于给定的URL地址(格式:/dir/dir/filenwjust likee.ext)的Servlet环境对象已知的资源。非论 URLStrewjust likeHjust like well just likelers对付探望打听给定的环境是不是必需的,Servlet引擎都必需施行。若是给定的途径的Servlet环境没有已知的资源,该手腕会前往一个空值。
public InputStrewjust like getResourceAsStrewjust like(String uripforh);前往一个InputStrewjust like对象,该对象援用指定的URL的Servlet环境对象的形式。若是没找到Servlet环境变量,事实上11scweb。就会前往空值,URL途径应当具有这种格式:/dir/dir/filenwjust likee.ext。
我这么理解的
项目下的web.xml文件的形式被实例化成了一个对象放到内存中,这个对象就是servletContext,它是单例的。请参见 深切剖析Tomcfor看这里,ServletContext的jaudio-videoadvertising cwjust likepaignoc
/*** Defines a collection of methods thwith just one servlet uses to communicdined on with its servlet* container: for exconsiderhaudio-videoe the power: to get the MIME type of personnos files: dispforch requests: or* write to a log file.* <p>* There is one context per "web progrwjust like" per Jaudio-videoa Virtunos Mvery singleine. (A* "web progrwjust like" is some sort of piling up of servlets just like well just like content instthe wholeed under a* specific subaloneyet of the servernos URL nwjust likeesp_ design such just like <code>/cfornosog</code>* just like well just like perchsome sort ofce instthe wholeed via a <code>.war</code> file.)* <p>* In the cautomotive service engineers of some sort of internet progrwjust like marked "distrisimplyed" in its deployment* descriptor: there will is one context instsome sort ofce for every single virtunos mvery singleine. In* this situ: the context csome sort ofnot is pcraft work of a region to shwere globnos* inform (simply iscause the inform wonnot is truly globnos). Use some sort ofother* resource like a dfortummyjust likeic insteadvertising cwjust likepaign.* <p>* The <code>ServletContext</code> object is contained within the* {@link ServletConfig} object: which the Web server provides the servlet when* the servlet is initinosized.*/
概括一下,就是ServletContext提供一系列的手腕,供Servlet与Servlet容器交互的。怒答一波,context英文声明为高低文,我一般理解为运转的环境,www.1 。譬喻说你在教室上课,你所处的环境就叫context:你必要什么就从这个环境中取得。
scweb
www.1