java - Declaring Integers, Doubles, Floats, Strings etc. in Spring XML -
Occasionally, Spring can not understand how a "value" should be. This happens when the property or manufacturer is of "java.lang.Object" type. In these cases, this is sometimes not the right option for Spring Default "java.lang.String", for example:
& lt; G: jndi-lookup id = "test" jndi-name = "Java: comp / env / test" default-value = "10" expected-type = "java.lang.Integer" />
If lookup fails and it needs to come back to the default-value, then there is one kind of mismatch. Therefore, instead, it needs to:
& lt; Bean id = "test" category = "org.springframework.jndi.JndiObjectFactoryBean" & gt; & Lt; Property Name = "jndiName" value = "java: comp / env / test" /> & Lt; Property Name = "Default Object" & gt; & Lt; Bean class = "java.lang.Integer" & gt; & Lt; Constructor-erg standard = "10" /> & Lt; / Bean & gt; & Lt; / Property & gt; & Lt; / Bean & gt;
which is an expression of some extent, especially if there are lots of them
and lieutenant; Bean class = There is no easy way to declare an integer / long / double / float / string literally without using this string: "java.lang.Integer" & gt; & Lt; Constructor-erg standard = "10" /> & Lt; / Bean & gt; Since Spring 3.0, you can use the Spring Expression language: # {new}
Integer (10)}
& lt; G: jndi-lookup id = "test" jndi-name = "java: comp / env / test" default-value = "# {new integer (10)}" expected-type = "java.lang.Integer" / Gt;
Comments
Post a Comment