Package org.springframework.web.util
Class ServletContextPropertyUtils
java.lang.Object
org.springframework.web.util.ServletContextPropertyUtils
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: for example, ${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:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
ServletContextPropertyUtils
public ServletContextPropertyUtils()
-
-
Method Details
-
resolvePlaceholders
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:
-
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 isfalse
- See Also:
-