Merge branch '5.2.x'

This commit is contained in:
Juergen Hoeller
2020-05-18 14:24:33 +02:00
6 changed files with 46 additions and 44 deletions

View File

@@ -539,8 +539,12 @@ example shows:
</bean>
----
The `systemProperties` variable is predefined, so you can use it in your expressions, as
the following example shows:
All beans in the application context are available as predefined variables with their
common bean name. This includes standard context beans such as `environment` (of type
`org.springframework.core.env.Environment`) as well as `systemProperties` and
`systemEnvironment` (of type `Map<String, Object>`) for access to the runtime environment.
The following example shows access to the `systemProperties` bean as a SpEL variable:
[source,xml,indent=0,subs="verbatim"]
----
@@ -551,8 +555,7 @@ the following example shows:
</bean>
----
Note that you do not have to prefix the predefined variable with the `#`
symbol in this context.
Note that you do not have to prefix the predefined variable with the `#` symbol here.
You can also refer to other bean properties by name, as the following example shows:
@@ -576,8 +579,8 @@ You can also refer to other bean properties by name, as the following example sh
[[expressions-beandef-annotation-based]]
=== Annotation Configuration
To specify a default value, you can place the `@Value` annotation on fields, methods, and method or constructor
parameters.
To specify a default value, you can place the `@Value` annotation on fields, methods,
and method or constructor parameters.
The following example sets the default value of a field variable:
@@ -1675,7 +1678,7 @@ The following example shows how to use the Elvis operator:
----
ExpressionParser parser = new SpelExpressionParser();
String name = parser.parseExpression("name?:'Unknown'").getValue(String.class);
String name = parser.parseExpression("name?:'Unknown'").getValue(new Inventor(), String.class);
System.out.println(name); // 'Unknown'
----
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -1683,7 +1686,7 @@ The following example shows how to use the Elvis operator:
----
val parser = SpelExpressionParser()
val name = parser.parseExpression("name?:'Unknown'").getValue(String::class.java)
val name = parser.parseExpression("name?:'Unknown'").getValue(Inventor(), String::class.java)
println(name) // 'Unknown'
----