where a is Integer. How can I...">

How to set null to Integer in spring context

this is a small part of my context:

<property name="a" value="1"/> where a is Integer. 

How can I set null for this value?

+6
source share
2 answers

You can use the <null/> element to specify a null value:

 <property name="a" value="1"/><null/></property> 

Edit: The official spring 2.5 documentation has more info: http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-null-element p>

+12
source

There is a way to set the value to zero in the Spring configuration file.

Spring:

 <bean class="SampleBean"> <property name="name"><value></value></property> </bean> 

The results in the name property are set to ", which is equivalent to the java code: sampleBean.setName (" "). The special <null> element can be used to specify a null value, so:

Spring:

 <bean class="ExampleBean"> <property name="email"><null/></property> </bean> 

The above configuration is equivalent to java code:

Java:

 exampleBean.setEmail(null). 

See this link: http://www.java-forums.org/java-tip/3218-how-set-null-value-springs-configuration-file.html

+2
source

Source: https://habr.com/ru/post/916916/


All Articles