SpringMVC的ServletContext、根上下文和MVC上下文上分别有什么东西?


WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
out.println(
" [LOCATOR_FACTORY_SELECTOR_PARAM] " + ContextLoader.LOCATOR_FACTORY_SELECTOR_PARAM +
" [LOCATOR_FACTORY_KEY_PARAM] " + ContextLoader.LOCATOR_FACTORY_KEY_PARAM +
" [CONFIG_LOCATION_PARAM] " + ContextLoader.CONFIG_LOCATION_PARAM +
" [CONTEXT_CLASS_PARAM] " + ContextLoader.CONTEXT_CLASS_PARAM +
" [CONTEXT_ID_PARAM] " + ContextLoader.CONTEXT_ID_PARAM +
" [CONTEXT_INITIALIZER_CLASSES_PARAM] " + ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM +
" [GLOBAL_INITIALIZER_CLASSES_PARAM] " + ContextLoader.GLOBAL_INITIALIZER_CLASSES_PARAM
);

if (wac != null) {
out.println(
" WAC getClassLoader " + wac.getClassLoader() +
" WAC getServletContext " + wac.getServletContext() +
" WAC getDisplayName " + wac.getDisplayName() +
" WAC getBeanDefinitionNames " + wac.getBeanDefinitionNames().toString() +
" WAC getApplicationName " + wac.getApplicationName() +
" WAC getBeanDefinitionCount " + wac.getBeanDefinitionCount() +
" WAC getEnvironment " + wac.getEnvironment()
);

ClassLoader cldr = wac.getClassLoader();
if (cldr != null) {
out.println(
" WAC getClassLoader getParent " + cldr.getParent() +
" WAC getClassLoader getClass " + cldr.getClass()
);
} else {
out.println("ContextLoader.getCurrentWebApplicationContext(); getClassLoader() nothing!");
}

ServletContext sc = wac.getServletContext();
if (sc != null) {
out.println(
" WAC getServletContext getServletContextName " + sc.getServletContextName() +
" WAC getServletContext getClassLoader " + sc.getClassLoader() +
" WAC getServletContext getClass " + sc.getClass() +
" WAC getServletContext getAttributeNames " + sc.getAttributeNames().toString() +
" WAC getServletContext getContextPath " + sc.getContextPath() +
// " getServletContext getInitParameterNames" + sc.getInitParameterNames() +
" WAC getServletContext getInitParameterNames " + sc.getInitParameterNames().toString() +
" WAC getServletContext getServerInfo " + sc.getServerInfo() +
" WAC getServletContext getSessionCookieConfig " + sc.getSessionCookieConfig()
);

Enumeration<String> es = sc.getAttributeNames();
while (es.hasMoreElements()){
String attr = es.nextElement().toString();
out.println(
" [Every Attribute oF ServletContext] getAttributeNames " + /*es.nextElement().toString()*/ attr
);
out.println(
" [[Every Attribute oF ServletContext] getAttribute] " + sc.getAttribute(attr)
);
}

// sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE).toString();

} else {
out.println("ContextLoader.getCurrentWebApplicationContext(); getServletContext() nothing!");
}

Environment env = wac.getEnvironment();
if (env != null) {
out.println(
" WAC getEnvironment getActiveProfiles " + env.getActiveProfiles().toString() +
" WAC getEnvironment getDefaultProfiles " + env.getDefaultProfiles().toString()
);
} else {
out.println("ContextLoader.getCurrentWebApplicationContext(); getServletContext() nothing!");
}

out.println(" ");
ApplicationContext ac = wac.getParent();
if (ac != null) {
out.println(
"AC getApplicationName " + ac.getApplicationName() +
"AC getDisplayName " + ac.getDisplayName() +
"AC getParent " + ac.getParent() +
"AC getBeanDefinitionNames " + ac.getBeanDefinitionNames() +
"AC getEnvironment " + ac.getEnvironment() +
"AC getClassLoader " + ac.getClassLoader() +
"AC getBeanDefinitionCount " + ac.getBeanDefinitionCount() +
"AC getParentBeanFactory " + ac.getParentBeanFactory()
);
} else {
out.println("wac.getParent() get nothing !");
}

BeanFactory bf = wac.getParentBeanFactory();
if (bf != null) {
out.println(
" BF getClass " + bf.getClass()
);

out.println(" ");
} else {
out.println("wac.getParentBeanFactory() get nothing ...");
}
} else {
out.println("ContextLoader.getCurrentWebApplicationContext() nothing !!");
}
[LOCATOR_FACTORY_SELECTOR_PARAM]        locatorFactorySelector
[LOCATOR_FACTORY_KEY_PARAM]     parentContextKey
[CONFIG_LOCATION_PARAM] contextConfigLocation
[CONTEXT_CLASS_PARAM]   contextClass
[CONTEXT_ID_PARAM]      contextId
[CONTEXT_INITIALIZER_CLASSES_PARAM]     contextInitializerClasses
[GLOBAL_INITIALIZER_CLASSES_PARAM]      globalInitializerClasses

WAC getClassLoader      WebAppClassLoader=1446511153@56380231
WAC getServletContext   ServletContext@o.e.j.m.p.JettyWebAppContext@702b06fb{/,file:///......../src/main/webapp/,AVAILABLE}{file:///......../src/main/webapp/}
WAC getDisplayName      Root WebApplicationContext
WAC getBeanDefinitionNames      [Ljava.lang.String;@29445b63
WAC getApplicationName
WAC getBeanDefinitionCount      2
WAC getEnvironment      StandardServletEnvironment {activeProfiles=[], defaultProfiles=[default], propertySources=[servletConfigInitParams,servletContextInitParams,jndiProperties,systemProperties,systemEnvironment]}

        WAC getClassLoader getParent    ClassRealm[plugin>org.eclipse.jetty:jetty-maven-plugin:9.4.1.v20170120, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
        WAC getClassLoader getClass     class org.eclipse.jetty.webapp.WebAppClassLoader

        WAC getServletContext getServletContextName     /
        WAC getServletContext getClassLoader    WebAppClassLoader=1446511153@56380231
        WAC getServletContext getClass  class org.eclipse.jetty.webapp.WebAppContext$Context
        WAC getServletContext getAttributeNames java.util.Collections$3@f64d5d7
        WAC getServletContext getContextPath
        WAC getServletContext getInitParameterNames     java.util.Collections$3@9cf986c
        WAC getServletContext getServerInfo     jetty/9.4.1.v20170120
        WAC getServletContext getSessionCookieConfig    org.eclipse.jetty.server.session.SessionHandler$CookieConfig@3687d044
                [Every Attribute oF ServletContext] getAttributeNames   javax.servlet.context.tempdir
                        [Every Attribute oF ServletContext getAttribute]        E:JavaTryCatchspring-mvc-showcase	arget	mp
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern
                        [Every Attribute oF ServletContext getAttribute]        .*/javax.servlet-[^/]*.jar$|.*/servlet-api-[^/]*.jar$|.*javax.servlet.jsp.jstl-[^/]*.jar|.*taglibs-standard-impl-.*.jar
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.util.DecoratedObjectFactory
                        [Every Attribute oF ServletContext getAttribute]        org.eclipse.jetty.util.DecoratedObjectFactory[decorators=3]
                [Every Attribute oF ServletContext] getAttributeNames   org.springframework.web.servlet.FrameworkServlet.CONTEXT.appServlet
                        [Every Attribute oF ServletContext getAttribute]        WebApplicationContext for namespace 'appServlet-servlet': startup date [Mon Jun 12 14:39:46 CST 2017]; parent: Root WebApplicationContext
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.SCI
                        [Every Attribute oF ServletContext getAttribute]        WebSocketUpgradeFilter[configuration=org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration@3d131ab4]
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.resource.postOverlay
                        [Every Attribute oF ServletContext getAttribute]        file:///E:/JavaTryCatch/spring-mvc-showcase/src/main/webapp/
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.lifecyleCallbackCollection
                        [Every Attribute oF ServletContext getAttribute]        org.eclipse.jetty.plus.annotation.LifeCycleCallbackCollection@1470aaac
                [Every Attribute oF ServletContext] getAttributeNames   resourceCache
                        [Every Attribute oF ServletContext getAttribute]        ResourceCache[null,org.eclipse.jetty.servlet.DefaultServlet@61095cb6]@1770300707
                [Every Attribute oF ServletContext] getAttributeNames   org.apache.tomcat.InstanceManager
                        [Every Attribute oF ServletContext getAttribute]        org.apache.tomcat.SimpleInstanceManager@4c67c41d
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration
                        [Every Attribute oF ServletContext getAttribute]        org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration@3d131ab4
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.tmpdirConfigured
                        [Every Attribute oF ServletContext getAttribute]        true
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.server.Executor
                        [Every Attribute oF ServletContext getAttribute]        qtp1728924984{STARTED,8<=12<=200,i=6,q=0}
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.injectionCollection
                        [Every Attribute oF ServletContext getAttribute]        org.eclipse.jetty.plus.annotation.InjectionCollection@5dd332f7
                [Every Attribute oF ServletContext] getAttributeNames   org.apache.catalina.jsp_classpath
                        [Every Attribute oF ServletContext getAttribute]        ......spring-mvc-showcase	argetclasses;.......m2
epositoryorgspringframeworkspring-context4.3.5.RELEASEspring-co
ntext-4.3.5.RELEASE.jar;...................................m2
epositorycommons-loggingcommons-logging1.2commons-logging-1.2.jar
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.runAsCollection
                        [Every Attribute oF ServletContext getAttribute]        org.eclipse.jetty.plus.annotation.RunAsCollection@76143917
                [Every Attribute oF ServletContext] getAttributeNames   org.apache.jasper.compiler.ELInterpreter
                        [Every Attribute oF ServletContext getAttribute]        org.apache.jasper.compiler.ELInterpreterFactory$DefaultELInterpreter@3a75274b
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.containerInitializerStarter
                        [Every Attribute oF ServletContext getAttribute]        org.eclipse.jetty.annotations.ServletContainerInitializersStarter@48c05b34
                [Every Attribute oF ServletContext] getAttributeNames   org.apache.jasper.compiler.TldCache
                        [Every Attribute oF ServletContext getAttribute]        org.apache.jasper.compiler.TldCache@c409c51
                [Every Attribute oF ServletContext] getAttributeNames   org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcherServlet
                        [Every Attribute oF ServletContext getAttribute]        WebApplicationContext for namespace 'dispatcherServlet-servlet': startup date [Mon Jun 12 14:39:44 CST 2017]; parent: Root WebApplicationCon
text
                [Every Attribute oF ServletContext] getAttributeNames   org.springframework.web.context.WebApplicationContext.ROOT
                        [Every Attribute oF ServletContext getAttribute]        Root WebApplicationContext: startup date [Mon Jun 12 14:39:43 CST 2017]; root of context hierarchy
                [Every Attribute oF ServletContext] getAttributeNames   org.springframework.web.context.support.ServletContextScope
                        [Every Attribute oF ServletContext getAttribute]        org.springframework.web.context.support.ServletContextScope@5b4bd04f
                [Every Attribute oF ServletContext] getAttributeNames   org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter
                        [Every Attribute oF ServletContext getAttribute]        WebSocketUpgradeFilter[configuration=org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration@3d131ab4]
                [Every Attribute oF ServletContext] getAttributeNames   javax.websocket.server.ServerContainer
                        [Every Attribute oF ServletContext getAttribute]        org.eclipse.jetty.websocket.jsr356.server.ServerContainer@4817eb12
                [Every Attribute oF ServletContext] getAttributeNames   org.apache.jasper.runtime.JspApplicationContextImpl
                        [Every Attribute oF ServletContext getAttribute]        org.apache.jasper.runtime.JspApplicationContextImpl@24400df

        WAC getEnvironment getActiveProfiles    [Ljava.lang.String;@a6eb6d2
        WAC getEnvironment getDefaultProfiles   [Ljava.lang.String;@fa2c678




wac.getParent() get nothing !
wac.getParentBeanFactory() get nothing ...
原文地址:https://www.cnblogs.com/andypeker/p/6992869.html