Placeholder configurers allow for trimming of property values
Issue: SPR-5839
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,7 +69,9 @@ class PropertyPlaceholderBeanDefinitionParser extends AbstractPropertyLoadingBea
|
||||
if (element.hasAttribute("value-separator")) {
|
||||
builder.addPropertyValue("valueSeparator", element.getAttribute("value-separator"));
|
||||
}
|
||||
|
||||
if (element.hasAttribute("trim-values")) {
|
||||
builder.addPropertyValue("trimValues", element.getAttribute("trim-values"));
|
||||
}
|
||||
if (element.hasAttribute("null-value")) {
|
||||
builder.addPropertyValue("nullValue", element.getAttribute("null-value"));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -167,9 +167,12 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
|
||||
StringValueResolver valueResolver = new StringValueResolver() {
|
||||
@Override
|
||||
public String resolveStringValue(String strVal) {
|
||||
String resolved = ignoreUnresolvablePlaceholders ?
|
||||
String resolved = (ignoreUnresolvablePlaceholders ?
|
||||
propertyResolver.resolvePlaceholders(strVal) :
|
||||
propertyResolver.resolveRequiredPlaceholders(strVal);
|
||||
propertyResolver.resolveRequiredPlaceholders(strVal));
|
||||
if (trimValues) {
|
||||
resolved = resolved.trim();
|
||||
}
|
||||
return (resolved.equals(nullValue) ? null : resolved);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user