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:

Table 1. Table 1. Escaping EL Examples
Expression Value Notes
${abc} xyz
$${abc} ${abc}
$$${abc} $xyz
$$$${abc} $${abc}
$$$$${abc} $$xyz
I owe you $5 I owe you $5 No actual Expression is present here.
You owe me $$5 too You owe me $$5 too The $ character is not escaped because it does not immediately precede an Expression.
Unescaped $$${5 because no closing brace Unescaped $$${5 because no closing brace Because there is no closing brace here, there is no actual Expression and hence the $ characters are not escaped.
Unescaped $$${5} because no closing brace <Error> This expression is not valid because it equates to an escaped $, followed by ${5} and the ${5} is not a valid Expression. The number must be escaped.
Unescaped $$${'5'} because no closing brace Unescaped $ because no closing brace There is no attribute named 5 so the Expression evaluates to an empty string. The $$ evaluates to a single (escaped) $ because it immediately precedes an Expression.