jsp el中点运算符和括号之间的区别 [英] Difference Between dot operator and brackets in jsp el

查看:94
本文介绍了jsp el中点运算符和括号之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的课:

public class MyClass{
   String name;
   Map map;
   int [] arrInt;
//get  set
}

我创建对象:

MyClass  mc = new MyClass  ();

在jsp中,我可以这样编写代码:

In jsp I can write so code:

${mc.name}

${mc["name"]}

点运算符和方括号运算符之间存在区别吗?

There are exist differencies between dot operator and bracket operator ?

推荐答案

它们的含义完全相同.点样式通常更易于阅读.如果索引将由表达式给出(例如mc[name]而不是mc["name"]),则需要方括号样式.

They have exactly the same meaning. The dot style is often easier to read. You need the bracket style if the index is going to be given by an expression (e.g. mc[name] instead of mc["name"]).

这篇关于jsp el中点运算符和括号之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆