类 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.- 从以下版本开始:
- 3.2.2
- 作者:
- Juergen Hoeller, Marten Deinum
- 另请参阅:
SystemPropertyUtils
,ServletContext.getInitParameter(String)
构造器概要
构造器 构造器 说明 ServletContextPropertyUtils()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 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.
构造器详细资料
ServletContextPropertyUtils
public ServletContextPropertyUtils()
方法详细资料
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.- 参数:
text
- the String to resolveservletContext
- the servletContext to use for lookups.- 返回:
- the resolved String
- 抛出:
IllegalArgumentException
- if there is an unresolvable placeholder- 另请参阅:
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.- 参数:
text
- the String to resolveservletContext
- the servletContext to use for lookups.ignoreUnresolvablePlaceholders
- flag to determine is unresolved placeholders are ignored- 返回:
- the resolved String
- 抛出:
IllegalArgumentException
- if there is an unresolvable placeholder and the flag is false- 另请参阅:
SystemPropertyUtils.PLACEHOLDER_PREFIX
,SystemPropertyUtils.PLACEHOLDER_SUFFIX
,SystemPropertyUtils.resolvePlaceholders(String, boolean)