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.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3833 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Oliver Gierke 2010-12-28 09:42:58 +00:00
parent 4e90c0a81f
commit 5e40c020fb
1 changed files with 9 additions and 0 deletions

View File

@ -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>