1

I'm using this functionality since a while without knowing why I can use it: in a jsp page why I can call a getter method of a Dto without the 'get' part?

For example if my Dto class PersonDto has a method called getName(), in my jsp I can do this:

 ${person.name}

instead of this:

 ${person.getName()}

Is a characteristic of Spring framework, of MVC pattern, JSTL or a combination of them ? And where can I study this argument?

franbisc
  • 59
  • 1
  • 14

2 Answers2

3

Is a characteristic of Spring framework, of MVC pattern, JSTL or a combination of them ?

None of them. It's called EL (Expression Language).

And where can I study this argument?

Start at our EL wiki page.


Noted should be that ${person.getName()} syntax was illegal until EL version 2.2. It's thus certainly not so that ${person.name} is newer than ${person.getName()}.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
1

It all goes back to the JavaBeans specification, which demands that for a field named foo, there must be a setter setFoo() and getter getFoo() (or isFoo() also permitted for boolean fields).

This allows for frameworks, template languages and other tools to use a simplified syntax, since it is known that bar.foo implies bar.getFoo().

Kayaman
  • 72,141
  • 5
  • 83
  • 121