org.springframework.web.util

Class ServletContextPropertyUtils

  • java.lang.Object
    • org.springframework.web.util.ServletContextPropertyUtils


  • public abstract class ServletContextPropertyUtils
    extends java.lang.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)
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.String resolvePlaceholders(java.lang.String text, ServletContext servletContext)
      Resolve ${...} placeholders in the given text, replacing them with corresponding servlet context init parameter or system property values.
      static java.lang.String resolvePlaceholders(java.lang.String text, ServletContext servletContext, boolean ignoreUnresolvablePlaceholders)
      Resolve ${...} placeholders in the given text, replacing them with corresponding servlet context init parameter or system property values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ServletContextPropertyUtils

        public ServletContextPropertyUtils()
    • Method Detail

      • resolvePlaceholders

        public static java.lang.String resolvePlaceholders(java.lang.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:
        java.lang.IllegalArgumentException - if there is an unresolvable placeholder and the flag is false
        See Also:
        SystemPropertyUtils.PLACEHOLDER_PREFIX, SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.resolvePlaceholders(String, boolean)