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:
  • Constructor Details

    • ServletContextPropertyUtils

      public ServletContextPropertyUtils()
  • Method Details

    • 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 resolve
      servletContext - 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 resolve
      servletContext - 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)