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

 


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

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

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

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

Enumeration<String> es = sc.getAttributeNames();
while (es.hasMoreElements()){
String attr = es.nextElement().toString();
out.println(
"\t\t[Every Attribute oF ServletContext] getAttributeNames\t" + /*es.nextElement().toString()*/ attr
);
out.println(
"\t\t\t[[Every Attribute oF ServletContext] getAttribute]\t" + 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(
"\n\tWAC getEnvironment getActiveProfiles\t" + env.getActiveProfiles().toString() +
"\n\tWAC getEnvironment getDefaultProfiles\t" + env.getDefaultProfiles().toString()
);
} else {
out.println("ContextLoader.getCurrentWebApplicationContext(); getServletContext() nothing!");
}

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

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

out.println("\n\n\n");
} 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:\JavaTryCatch\spring-mvc-showcase\target\tmp
                [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\target\classes;......\.m2\repository\org\springframework\spring-context\4.3.5.RELEASE\spring-co
ntext-4.3.5.RELEASE.jar;...................................m2\repository\commons-logging\commons-logging\1.2\commons-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 ...

 

posted @ 2017-06-12 14:30  FranklinYang  阅读(1599)  评论(0编辑  收藏  举报