Escaping Expression Language
There may be times when a property supports Expression Language, but the user wishes to use a literal value that follows the same syntax as the Expression Language. For example, a user may want to configure a property value to be the literal text Hello ${UserName}
. In such a case, this can be accomplished by using an extra $
(dollar sign symbol) just before the expression to escape it (i.e., Hello $${UserName}
). Unless the $
character is being used to escape an Expression, it should not be escaped. For example, the value Hello $$User$$Name
should not escape the $
characters, so the literal value that will be used is Hello $$User$$Name
.
If more than two $
characters are encountered sequentially before a {
, then each pair of $
characters will be considered an escaping of the $
character. The escaping will be performed from left-to-right. To help illustrate this, consider that the variable abc
contains the value xyz
. Then, consider the following table of Expressions and their corresponding evaluated values:
Expression |
Value |
Notes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
No actual Expression is present here. |
|
|
The $ character is not escaped because it does not immediately precede an Expression. |
|
|
Because there is no closing brace here, there is no actual Expression and hence the $ characters are not escaped. |
|
<Error> |
This expression is not valid because it equates to an escaped $, followed by |
|
|
There is no attribute named |