• April 25, 2016
  • Spring
  • Comments Off on Spring spel ternary operator example

Spring spel ternary operator 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.

Ternary operator syntax:

condition ? true : false

Spring SpEL Ternary Operator Example:


import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
 * Spring SPEL Ternary Operator test example.
 * @author javawithease
public class TernaryOperatorTest {
	public static void main(String args[]){
		//Create a parser with default settings.
		ExpressionParser parser = new SpelExpressionParser(); 
		//Ternary operator expressions. 
				"10 < 20? true: false").getValue());



Download this example.

Comments are closed.