开发者

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 to expr-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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜