Tutorialspoint examples

Learn java tutorial with examples for beginners online

Spring spel operators example

Spring SpEL:

The SpEL stands for Spring Expression Language. It is a powerful expression language which supports querying and manipulating an object graph at the bean creation time or run time. It is similar to other expression languages like JSP EL, OGNL, MVEL and JBoss EL etc with some additional features like method invocation and basic string templating functionality.

Spring SpEL Operators:

SpEL supports the mathematical operators (+, -, /, *, %, ^), logical operators (and, or, not) and relational operators (==, !=, <, <=, >, >=).



import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
 * Spring SPEL Operator test example.
 * @author javawithease
public class OperatorTest {
 public static void main(String args[]){
  //Create a parser with default settings.
  ExpressionParser parser = new SpelExpressionParser(); 
  //Arithmetic operator expressions. 
  System.out.println(parser.parseExpression("10 * 20").getValue());  
  System.out.println(parser.parseExpression("" +
	"'Today is: '+ new java.util.Date()").getValue()); 
  //Relational operator expressions. 
  //Logical operator expressions.  
                             "(10 > 5) and (5>3)").getValue()); 	  


Today is: Mon Apr 25 16:00:45 IST 2016

Download this example.

Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status