Home  >  Spring Core

Relational and Logical operators in Spring Expression Language (SpEL)

By Arvind Rai, October 06, 2013
In this page, we will see the example of relational and logical operators in spring expression language. Parser will parse the value as true and false and return Boolean data type.

Relational Operators in Spring Expression Language

package com.concretepage;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
public class SpELTest {
	public static void main(String[] args) {
		ExpressionParser parser = new SpelExpressionParser();
		boolean bol = parser.parseExpression("20 == 20").getValue(Boolean.class);
		System.out.println(bol);
		
	    bol = parser.parseExpression("20 == 50").getValue(Boolean.class);
		System.out.println(bol);
	}
}
 

Logical Operators in Spring Expression Language

package com.concretepage;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
public class SpELTest {
	public static void main(String[] args) {
		ExpressionParser parser = new SpelExpressionParser();
		boolean bol = parser.parseExpression("true == true").getValue(Boolean.class);
		System.out.println(bol);
		
	    bol = parser.parseExpression("true == false").getValue(Boolean.class);
		System.out.println(bol);
	}
}
 
POSTED BY
ARVIND RAI
ARVIND RAI
FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us