Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

Operators in SPEL


We can use many operators in SpEL such as arithmetic, relational, logical etc. There are given a lot of examples of using different operators in SpEL.


Examples of using operators in SPEL

  1. import org.springframework.expression.ExpressionParser;
  2. import org.springframework.expression.spel.standard.SpelExpressionParser;
  3. public class Test {
  4. public static void main(String[] args) {
  5. ExpressionParser parser = new SpelExpressionParser();
  6. //arithmetic operator
  7. System.out.println(parser.parseExpression(“‘Welcome SPEL’+’!'”).getValue());
  8. System.out.println(parser.parseExpression(“10 * 10/2”).getValue());
  9. System.out.println(parser.parseExpression(“‘Today is: ‘+ new java.util.Date()”).getValue());
  10. //logical operator
  11. System.out.println(parser.parseExpression(“true and true”).getValue());
  12. //Relational operator
  13. System.out.println(parser.parseExpression(“‘sonoo’.length()==5”).getValue());
  14. }
  15. }

Comments

comments