Inline lists and Inline Maps in SpEL by R4R Team

Inline lists and Inline Maps in SpEL:-
Lists can be expressed directly in an expression using {} notation.

//evaluates to a Spring list containing the three numbers

List num = (List) parser.parseExpression("{1,2,3,}").getValue(context);

List listOfLists = (List) parser.parseExpression("{{'a','b'},{'x','y'}}").getValue(context);

Maps can also be expressed directly in an expression using {key:value} notation.

//evaluates to a Spring map containing the two entries

Map map = (Map) parser.parseExpression("{name:'Vipul',dob:'01-July-1999'}").getValue(context);

Map mapOfMaps = (Map) parser.parseExpression("{name:{first:'Vipul',last:'Sharma'},dob:{day:01,month:'July',year:1999}}").getValue(context);

 

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!