之间的区别。 EL 中的运算符和 []
difference between . operator and [] in EL
这个问题可能看起来很愚蠢而且很天真,但我总是搞不清楚如何使用 .和 EL 中的 [] 运算符。我迷失在问题 7 "Head first Servlet &JSP" 中。所以我的困惑
${foo[bar]}
和${foo["bar"]}
有什么区别
为什么 ${foo.bar}
等于 ${foo["bar"]}
而不是 ${foo[bar]}
如何得出结论 ${foo["5"]}
对 Map 有效,对 Array 或 list 无效
如何得出结论 ${foo[5]}
对 Array 或 List 有效,对 Maps 无效。
我看了这本书,但仍然很困惑。
请有人指导我。
提前致谢
- what is difference between ${foo[bar]} and ${foo["bar"]}
两者的区别在于前者访问的是foo
使用 bar 变量的集合,而在后者中,您试图从地图 foo[= 中检索键 bar 37=]
- How come ${foo.bar} equal to ${foo["bar"]} and not ${foo[bar]}
因为 ${foo.bar}
只是意味着 bar 就像 foo 的一个属性,因此对 ${foo.bar}
和 ${foo["bar"]}
相似。对于 ${foo[bar]}
,这也可以类似于 ${foo["bar"]}
,具体取决于 bar
的类型。
- How to conclude ${foo["5"]} is valid for Map and not for Array or list
因为"5"
是字符串而不是整数。
- How to conclude ${foo[5]} is valid for Array or List and not for Maps.
与上述问题类似的论点,5是一个整数。
我的EL技能有点生疏,不妥之处还请见谅
这个问题可能看起来很愚蠢而且很天真,但我总是搞不清楚如何使用 .和 EL 中的 [] 运算符。我迷失在问题 7 "Head first Servlet &JSP" 中。所以我的困惑
${foo[bar]}
和${foo["bar"]}
有什么区别
为什么
${foo.bar}
等于${foo["bar"]}
而不是${foo[bar]}
如何得出结论
${foo["5"]}
对 Map 有效,对 Array 或 list 无效如何得出结论
${foo[5]}
对 Array 或 List 有效,对 Maps 无效。
我看了这本书,但仍然很困惑。 请有人指导我。 提前致谢
- what is difference between ${foo[bar]} and ${foo["bar"]}
两者的区别在于前者访问的是foo 使用 bar 变量的集合,而在后者中,您试图从地图 foo[= 中检索键 bar 37=]
- How come ${foo.bar} equal to ${foo["bar"]} and not ${foo[bar]}
因为 ${foo.bar}
只是意味着 bar 就像 foo 的一个属性,因此对 ${foo.bar}
和 ${foo["bar"]}
相似。对于 ${foo[bar]}
,这也可以类似于 ${foo["bar"]}
,具体取决于 bar
的类型。
- How to conclude ${foo["5"]} is valid for Map and not for Array or list
因为"5"
是字符串而不是整数。
- How to conclude ${foo[5]} is valid for Array or List and not for Maps.
与上述问题类似的论点,5是一个整数。
我的EL技能有点生疏,不妥之处还请见谅