tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Spring > Expression Language > Root Variable

Root Variable 

The Spring Expression Language (SpEL) is a simple and powerful expression language which helps to query and manipulate objects at runtime. The following example shows accessing evaluation context root variable.

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.spring3.tests.spel;

import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

import com.bethecoder.tutorials.spring3.basic.Employee;

public class RootVariableTest {

   @param args
  public static void main(String[] args) {

    StandardEvaluationContext stdContext = 
      new StandardEvaluationContext(new Employee(1"ABC"9999));
    ExpressionParser parser = new SpelExpressionParser();
    Employee emp = parser.parseExpression("#root").getValue(stdContext, Employee.class);
    String name = parser.parseExpression("").getValue(stdContext, String.class);


It gives the following output,
Employee[1, ABC, 9999.0]


bl  br