What is the difference between two EL syntaxes?
I want to make form fields stable in JSP forms so I use:
${param.fieldName}
I tried to make like this:
${param["fieldame"]}
and also works!
Can someon开发者_开发百科e tell me what is the difference?
From Expression Language Specification Version 2.2 Maintenance Release:
1.6 Operators
[]
and.
expr-a.identifier-b
is equivalent toexpr-a["identifier-b"]
; that is, the identifier identifier-b is used to construct a literal whose value is the identifier, and then the[]
operator is used with that value.
In the param["fieldName"]
you can have any (valid) string between the quotes. In the param.fieldName you cannot have that, as it can only contain the characters that are valid for an identifier.
In both cases it maps to a lookup. What kind of lookup depends on what type "param" resolves to.
精彩评论