Property Navigation

MVEL property navigation follows well-established conventions found in other bean property expressions found in other languages such as Groovy, OGNL, EL, etc.

Unlike some other languages which require qualification depending on the underlying method of access, MVEL provides a single, unified syntax for accessing properties, static fields, maps, etc.

Bean Properties

Most java developers are familiar with and user the getter/setter paradigm in their Java objects in order to encapsulate property accessors.   For example, you might access a property from an object as such:

In order to simplify this, you can access the same property using the following expression:

Note: In situations where the field in the object is public, MVEL will still prefer to access the property via it's getter method.


Traversal of collections can also be achieved using abbreviated syntax.

List Access

Lists are accessed the same as array's. For example:

is the equivelent of the Java code:

Map Access

Maps are accessed in the same way as array's except any object can be passed as the index value. For example:

is the equivelent of the Java code:

For Maps that use a String as a key, you may use another special syntax:

... Allowing you to treat the Map itself as a virtual object.

Strings as Arrays

For the purposes of using property indexes (as well as iteration) all Strings are treated as arrays. In MVEL you may refer to the first character in a String variable as such:

Powered by Atlassian Confluence