Top Description Fields Methods
org.springframework.web.context

public Interface WebApplicationContext

extends ApplicationContext
Known Direct Subinterfaces
org.springframework.web.context.ConfigurableWebApplicationContext
Imports
jakarta.servlet.ServletContext, org.springframework.context.ApplicationContext, org.springframework.lang.Nullable

Interface to provide configuration for a web application. This is read-only while the application is running, but may be reloaded if the implementation supports this.

This interface adds a getServletContext() method to the generic ApplicationContext interface, and defines a well-known application attribute name that the root context must be bound to in the bootstrap process.

Like generic application contexts, web application contexts are hierarchical. There is a single root context per application, while each servlet in the application (including a dispatcher servlet in the MVC framework) has its own child context.

In addition to standard application context lifecycle capabilities, WebApplicationContext implementations need to detect ServletContextAware beans and invoke the setServletContext method accordingly.

Authors
Rod Johnson, Juergen Hoeller
Since
January 19, 2001
See Also
ServletContextAware#setServletContext

Field Summary

Modifier and TypeField and Description
public static final String
CONTEXT_ATTRIBUTES_BEAN_NAME

Name of the ServletContext attributes environment bean in the factory.

public static final String
CONTEXT_PARAMETERS_BEAN_NAME

Name of the ServletContext init-params environment bean in the factory.

public static final String
ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE

Context attribute to bind root WebApplicationContext to on successful startup.

public static final String
SCOPE_APPLICATION

Scope identifier for the global web application scope: "application".

public static final String
SCOPE_REQUEST

Scope identifier for request scope: "request".

public static final String
SCOPE_SESSION

Scope identifier for session scope: "session".

public static final String
SERVLET_CONTEXT_BEAN_NAME

Name of the ServletContext environment bean in the factory.

Method Summary

Modifier and TypeMethod and Description
public ServletContext
getServletContext()

Return the standard Servlet API ServletContext for this application.

Inherited from org.springframework.context.ApplicationContext:
getApplicationNamegetAutowireCapableBeanFactorygetDisplayNamegetIdgetParentgetStartupDate

Field Detail

CONTEXT_ATTRIBUTES_BEAN_NAMEback to summary
public static final String CONTEXT_ATTRIBUTES_BEAN_NAME

Name of the ServletContext attributes environment bean in the factory.

See Also
jakarta.servlet.ServletContext#getAttributeNames(), jakarta.servlet.ServletContext#getAttribute(String)
CONTEXT_PARAMETERS_BEAN_NAMEback to summary
public static final String CONTEXT_PARAMETERS_BEAN_NAME

Name of the ServletContext init-params environment bean in the factory.

Note

Possibly merged with ServletConfig parameters. ServletConfig parameters override ServletContext parameters of the same name.

See Also
jakarta.servlet.ServletContext#getInitParameterNames(), jakarta.servlet.ServletContext#getInitParameter(String), jakarta.servlet.ServletConfig#getInitParameterNames(), jakarta.servlet.ServletConfig#getInitParameter(String)
ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTEback to summary
public static final String ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE

Context attribute to bind root WebApplicationContext to on successful startup.

Note

If the startup of the root context fails, this attribute can contain an exception or error as value. Use WebApplicationContextUtils for convenient lookup of the root WebApplicationContext.

See Also
org.springframework.web.context.support.WebApplicationContextUtils#getWebApplicationContext, org.springframework.web.context.support.WebApplicationContextUtils#getRequiredWebApplicationContext
SCOPE_APPLICATIONback to summary
public static final String SCOPE_APPLICATION

Scope identifier for the global web application scope: "application". Supported in addition to the standard scopes "singleton" and "prototype".

SCOPE_REQUESTback to summary
public static final String SCOPE_REQUEST

Scope identifier for request scope: "request". Supported in addition to the standard scopes "singleton" and "prototype".

SCOPE_SESSIONback to summary
public static final String SCOPE_SESSION

Scope identifier for session scope: "session". Supported in addition to the standard scopes "singleton" and "prototype".

SERVLET_CONTEXT_BEAN_NAMEback to summary
public static final String SERVLET_CONTEXT_BEAN_NAME

Name of the ServletContext environment bean in the factory.

See Also
jakarta.servlet.ServletContext

Method Detail

getServletContextback to summary
public ServletContext getServletContext()

Return the standard Servlet API ServletContext for this application.

Annotations
@Nullable