欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

关于ServletContext实例中未被定义的配置信息Attribute

程序员文章站 2022-10-03 14:37:12
今天在工作中偶然发现ServletContext的实例中含有许多我们未定义的Attribute。这个可以用getAttributeNames方法来获取一个字符串型Enumeration列举来获得。查了一下,这些主要是Tomcat的配置信息。服务器启动时,ServletContext可能就已经被实例化了。而且如果对其实例新添加Attribute的话,用getAttributeNames来输出其所有Attribute名顺序也是不固定的。新添加的Attribute名的位置不会总是出现在列举的最后,不知道有没有...

今天在工作中偶然发现ServletContext的实例中含有许多我们未定义的Attribute。这个可以用getAttributeNames方法来获取一个字符串型Enumeration列举来获得。
查了一下,这些主要是Tomcat的配置信息。服务器启动时,ServletContext就已经被实例化了。

javax.servlet.context.tempdir org.apache.catalina.resources 2 org.apache.catalina.webappVersion org.apache.tomcat.InstanceManager org.apache.catalina.jsp_classpath javax.websocket.server.ServerContainer org.apache.jasper.compiler.ELInterpreter org.apache.jasper.compiler.TldCache org.apache.tomcat.JarScanner org.apache.jasper.runtime.JspApplicationContextImpl

javax.servlet.context.tempdir
org.apache.catalina.resources
2
org.apache.catalina.webappVersion
org.apache.tomcat.InstanceManager
org.apache.catalina.jsp_classpath
javax.websocket.server.ServerContainer
org.apache.jasper.compiler.ELInterpreter
org.apache.jasper.compiler.TldCache
org.apache.tomcat.JarScanner
org.apache.jasper.runtime.JspApplicationContextImpl

javax.servlet.context.tempdir
org.apache.catalina.resources
2
org.apache.catalina.webappVersion
org.apache.tomcat.InstanceManager
org.apache.catalina.jsp_classpath
javax.websocket.server.ServerContainer
org.apache.jasper.compiler.ELInterpreter
org.apache.jasper.compiler.TldCache
org.apache.tomcat.JarScanner
org.apache.jasper.runtime.JspApplicationContextImpl

javax.servlet.context.tempdir
org.apache.catalina.resources
org.apache.catalina.webappVersion
org.apache.tomcat.InstanceManager
org.apache.catalina.jsp_classpath
org.apache.jasper.compiler.ELInterpreter
org.apache.jasper.compiler.TldCache
org.apache.tomcat.JarScanner
2
3
javax.websocket.server.ServerContainer
org.apache.jasper.runtime.JspApplicationContextImpl

javax.servlet.context.tempdir
org.apache.catalina.resources
org.apache.catalina.webappVersion
org.apache.tomcat.InstanceManager
org.apache.catalina.jsp_classpath
org.apache.jasper.compiler.ELInterpreter
org.apache.jasper.compiler.TldCache
org.apache.tomcat.JarScanner
2
3
javax.websocket.server.ServerContainer
org.apache.jasper.runtime.JspApplicationContextImpl

javax.servlet.context.tempdir
org.apache.catalina.resources
org.apache.catalina.webappVersion
org.apache.tomcat.InstanceManager
org.apache.catalina.jsp_classpath
org.apache.jasper.compiler.ELInterpreter
org.apache.jasper.compiler.TldCache
org.apache.tomcat.JarScanner
2
3
4
javax.websocket.server.ServerContainer
org.apache.jasper.runtime.JspApplicationContextImpl

javax.servlet.context.tempdir
org.apache.catalina.resources
org.apache.catalina.webappVersion
org.apache.tomcat.InstanceManager
org.apache.catalina.jsp_classpath
org.apache.jasper.compiler.ELInterpreter
org.apache.jasper.compiler.TldCache
org.apache.tomcat.JarScanner
2
3
4
5
javax.websocket.server.ServerContainer
org.apache.jasper.runtime.JspApplicationContextImpl

而且如果对其实例新添加Attribute的话,用getAttributeNames来输出其所有Attribute名顺序也是不固定的。新添加的Attribute名的位置不会总是出现在列举的最后,不知道有没有大牛可以解释一下这个现象。

本文地址:https://blog.csdn.net/weixin_43935220/article/details/107698899

相关标签: java tomcat web