Top Description Inners Fields Constructors Methods
org.springframework.web.util

public abstract Class ServletContextPropertyUtils

extends Object
Class Inheritance
Imports
jakarta.servlet.ServletContext, org.springframework.lang.Nullable, org.springframework.util.PropertyPlaceholderHelper, .SystemPropertyUtils

Helper class for resolving placeholders in texts. Usually applied to file paths.

A text may contain ${...} placeholders, to be resolved as servlet context init parameters or system properties: e.g. ${user.dir}. Default values can be supplied using the ":" separator between key and value.

Authors
Juergen Hoeller, Marten Deinum
Since
3.2.2
See Also
SystemPropertyUtils, ServletContext#getInitParameter(String)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final PropertyPlaceholderHelper
private static final PropertyPlaceholderHelper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

the resolved String
resolvePlaceholders
(String
the String to resolve
text
,
ServletContext
the servletContext to use for lookups.
servletContext
)

Resolve ${...} placeholders in the given text, replacing them with corresponding servlet context init parameter or system property values.

public static String

Returns:

the resolved String
resolvePlaceholders
(String
the String to resolve
text
,
ServletContext
the servletContext to use for lookups.
servletContext
,
boolean
flag to determine is unresolved placeholders are ignored
ignoreUnresolvablePlaceholders
)

Resolve ${...} placeholders in the given text, replacing them with corresponding servlet context init parameter or system property values.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nonStrictHelperback to summary
private static final PropertyPlaceholderHelper nonStrictHelper
strictHelperback to summary
private static final PropertyPlaceholderHelper strictHelper

Constructor Detail

ServletContextPropertyUtilsback to summary
public ServletContextPropertyUtils()

Method Detail

resolvePlaceholdersback to summary
public static String resolvePlaceholders(String text, ServletContext servletContext)

Resolve ${...} placeholders in the given text, replacing them with corresponding servlet context init parameter or system property values.

Parameters
text:String

the String to resolve

servletContext:ServletContext

the servletContext to use for lookups.

Returns:String

the resolved String

Exceptions
IllegalArgumentException:
if there is an unresolvable placeholder
See Also
SystemPropertyUtils#PLACEHOLDER_PREFIX, SystemPropertyUtils#PLACEHOLDER_SUFFIX, SystemPropertyUtils#resolvePlaceholders(String, boolean)
resolvePlaceholdersback to summary
public static String resolvePlaceholders(String text, ServletContext servletContext, boolean ignoreUnresolvablePlaceholders)

Resolve ${...} placeholders in the given text, replacing them with corresponding servlet context init parameter or system property values. Unresolvable placeholders with no default value are ignored and passed through unchanged if the flag is set to true.

Parameters
text:String

the String to resolve

servletContext:ServletContext

the servletContext to use for lookups.

ignoreUnresolvablePlaceholders:boolean

flag to determine is unresolved placeholders are ignored

Returns:String

the resolved String

Exceptions
IllegalArgumentException:
if there is an unresolvable placeholder and the flag is false
See Also
SystemPropertyUtils#PLACEHOLDER_PREFIX, SystemPropertyUtils#PLACEHOLDER_SUFFIX, SystemPropertyUtils#resolvePlaceholders(String, boolean)
org.springframework.web.util back to summary

private Class ServletContextPropertyUtils.ServletContextPlaceholderResolver

extends Object
implements PlaceholderResolver
Class Inheritance
  • java.lang.Object
  • org.springframework.web.util.ServletContextPropertyUtils.ServletContextPlaceholderResolver
All Implemented Interfaces
org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver

Field Summary

Modifier and TypeField and Description
private final ServletContext
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
resolvePlaceholder(String
the name of the placeholder to resolve
placeholderName
)

Implements org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver.resolvePlaceholder.

Resolve the supplied placeholder name to the replacement value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

servletContextback to summary
private final ServletContext servletContext
textback to summary
private final String text

Constructor Detail

ServletContextPlaceholderResolverback to summary
public ServletContextPlaceholderResolver(String text, ServletContext servletContext)

Method Detail

resolvePlaceholderback to summary
public String resolvePlaceholder(String placeholderName)

Implements org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver.resolvePlaceholder.

Doc from org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver.resolvePlaceholder.

Resolve the supplied placeholder name to the replacement value.

Parameters
placeholderName:String

the name of the placeholder to resolve

Returns:String

the replacement value, or null if no replacement is to be made

Annotations
@Override
@Nullable