1.

What is SpEL (Spring Expression Language)?

Answer»

Spring Framework 3.0 introduced Expression LANGUAGE/ SpEL. In Spring Expression Language (SpEL), QUERIES and manipulations of object graphs are possible at runtime. You can use it with XML and annotation-based Spring configurations. JSP EL, OGNL, MVEL and JBoss EL are some of the expression languages available, but SpEL provides additional features INCLUDING string template functionality and method invocation. 

Example: 

import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser; public class WelcomeTest { public static void main(String[] args) { ExpressionParser parser = new SpelExpressionParser(); Expression EXP = parser.parseExpression("'WELCOMEtoSPEL'"); String message = (String) exp.getValue(); System.out.println(message); //OR //System.out.println(parser.parseExpression("'Hello SPEL'").getValue()); } }

Output:  

WELCOMEtoSPEL


Discussion

No Comment Found