0

I have a bean defined in my xml:

<bean class="myClass">
<property name="abc">
<value="${a}
${b}
${c}
" /></property>
</bean>

I don't want to put the values in one line. I want it to be in separate lines.

Property file:

a=abc'
b=def
c='xyz

The value in run time will be:

acb'    def    'xyz

How do I remove the white spaces from the value using springutils?

<bean class="myClass">
 <property name="abc">
 <bean class="org.springframework.util.StringUtils"
            factory-method="trimWhitespace">
            <constructor-arg type="java.lang.String">

<value="${a}
${b}
${c}
" /></bean></property>
</bean>

I'm looking for something like this - where I want to use trim function from java.lang.String:

<bean id="numberGuess" class="org.spring.samples.NumberGuess">
<property name="randomNumber" value="#{ T(java.lang.Math).random() * 100.0 }"/>

</bean>

Sorry for the mistake but its actually

acb '    def    ' xyz

There are white spaces after abc and before xyz and I need these white spaces but not inside the quotes

sandesh
  • 43
  • 7
  • Why is it so important that you have a value split up in such a way? Something along the lines `` (whith new-lines between a/b/c could work. – zapl Jun 08 '16 at 00:50
  • Why is it so important that you have a value split up in such a way? well, I have many keys like a,b,c to be appended for this property value and I want this to be dynamic as well. So, I want to change my property file instead of touching the xml and have enough readability as well I'm looking at a similar thing but I want something like this - – sandesh Jun 08 '16 at 15:41
  • is there anyway to do so? – sandesh Jun 08 '16 at 15:43
  • Usually people inject lists when there are multiple properties: http://stackoverflow.com/questions/37552665/spring-boot-populate-list-collection-from-application-properties/37553434#37553434 and the method linked in comments – zapl Jun 08 '16 at 16:08

1 Answers1

0

You can use line feed:

...
<value="${a}&#10;${b}&#10;${c}" />
...

Check all numeric code character entities: http://www.december.com/html/spec/codes.html

Arif Acar
  • 1,461
  • 2
  • 19
  • 33
  • I tried this, and this prints out - abc ' def ' xyz in multiple lines here I also see whitecaps after abc' and before 'xyz – sandesh Jun 08 '16 at 15:45