Can be combined with "locations" and/or "properties" values in addition
to web.xml context-params. Alternatively, can be defined without local
properties, to resolve all placeholders as web.xml context-params
(or JVM system properties).

If a placeholder could not be resolved against the provided local
properties within the application, this configurer will fall back to
ServletContext parameters. Can also be configured to let ServletContext
init parameters override local properties (contextOverride=true).

Optionally supports searching for ServletContext attributes: If turned
on, an otherwise unresolvable placeholder will matched against the corresponding
ServletContext attribute, using its stringified value if found. This can be
used to feed dynamic values into Spring's placeholder resolution.

If not running within a WebApplicationContext (or any other context that
is able to satisfy the ServletContextAware callback), this class will behave
like the default PropertyPlaceholderConfigurer. This allows for keeping
ServletContextPropertyPlaceholderConfigurer definitions in test suites.

resolvePlaceholder(String placeholder,
ServletContext servletContext,
boolean searchContextAttributes)
Resolves the given placeholder using the init parameters
and optionally also the attributes of the given ServletContext.

void

setContextOverride(boolean contextOverride)
Set whether ServletContext init parameters (and optionally also ServletContext
attributes) should override local properties within the application.

void

setSearchContextAttributes(boolean searchContextAttributes)
Set whether to search for matching a ServletContext attribute before
checking a ServletContext init parameter.

ServletContextPropertyPlaceholderConfigurer

public ServletContextPropertyPlaceholderConfigurer()

Method Detail

setContextOverride

public void setContextOverride(boolean contextOverride)

Set whether ServletContext init parameters (and optionally also ServletContext
attributes) should override local properties within the application.
Default is "false": ServletContext settings serve as fallback.

Note that system properties will still override ServletContext settings,
if the system properties mode is set to "SYSTEM_PROPERTIES_MODE_OVERRIDE".

setSearchContextAttributes

Set whether to search for matching a ServletContext attribute before
checking a ServletContext init parameter. Default is "false": only
checking init parameters.

If turned on, the configurer will look for a ServletContext attribute with
the same name as the placeholder, and use its stringified value if found.
Exposure of such ServletContext attributes can be used to dynamically override
init parameters defined in web.xml, for example in a custom
context listener.