SPR-7674 - Documented value defaulting in Spring EL

Added short note of how to use the Elvis operator for defaulting values in the Spring expression language sections.
master
Oliver Gierke 14 years ago
parent bfb3003cba
commit f20ded5f63
  1. 9
      spring-framework-reference/src/expressions.xml

@ -1011,6 +1011,15 @@ tesla.setPlaceOfBirth(null);
city = parser.parseExpression("PlaceOfBirth?.City").getValue(context, String.class);
System.out.println(city); // null - does not throw NullPointerException!!!</programlisting>
<note>
<para>The Elvis operator can be used to apply default values in
expressions, e.g. in an <interfacename>@Value</interfacename> expression:</para>
<programlisting>@Value("#{systemProperties['pop3.port'] ?: 25}")</programlisting>
<para>This will inject a system property <code>pop3.port</code> if it
is defined or 25 if not.</para>
</note>
</section>
<section>

Loading…
Cancel
Save