Package org.springframework.web.util
Class ServletContextPropertyUtils
- java.lang.Object
- org.springframework.web.util.ServletContextPropertyUtils
public abstract class ServletContextPropertyUtils extends Object
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.- Since:
- 3.2.2
- Author:
- Juergen Hoeller, Marten Deinum
- See Also:
SystemPropertyUtils
,ServletContext.getInitParameter(String)
Constructor Summary
Constructors Constructor Description ServletContextPropertyUtils()
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.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.
Constructor Detail
ServletContextPropertyUtils
public ServletContextPropertyUtils()
Method Detail
resolvePlaceholders
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
- the String to resolveservletContext
- the servletContext to use for lookups.- Returns:
- the resolved String
- Throws:
IllegalArgumentException
- if there is an unresolvable placeholder- See Also:
SystemPropertyUtils.PLACEHOLDER_PREFIX
,SystemPropertyUtils.PLACEHOLDER_SUFFIX
,SystemPropertyUtils.resolvePlaceholders(String, boolean)
resolvePlaceholders
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
- the String to resolveservletContext
- the servletContext to use for lookups.ignoreUnresolvablePlaceholders
- flag to determine is unresolved placeholders are ignored- Returns:
- the resolved String
- Throws:
IllegalArgumentException
- if there is an unresolvable placeholder and the flag is false- See Also:
SystemPropertyUtils.PLACEHOLDER_PREFIX
,SystemPropertyUtils.PLACEHOLDER_SUFFIX
,SystemPropertyUtils.resolvePlaceholders(String, boolean)