Spring Expression Language

  • Support passing and executing expression with help of @value annotation.
  • To get a bean by id to set property type we can Use @value(“#{student}”).
  • We can pass classes, variable methods, Constructors and objects in the expression.
    • For example @value(“{expression}”)
  • We can also use symbols like char, Numbers, operator , keywords And special symbols which turn our value
    • @value(“#{3+5}”)
    • @value(“#{8>6?88:55}”)
  • We can call static methods, object, methods and variables.
  • To invoke static method and variable. In spring expression, we use following methods.
    • T(classname).method(Param)
    • T(classname).variable
  • For example if we want to invoke sqrt method of java.lang.math we will invoke as follows
    • T(java.lang.math).sqrt(5).
  • For Objects
    • new Object(Value)
  • For Boolean type with Spring Programming Expresson Language(SPEL)
    • @value(“#{8>3}”)
    • We need to place an expression which resolves in Boolean.

No comments:

Post a Comment

Spring Boot

What is circular/cyclic dependency in spring boot? When two services are interdependent on each other, that is to start one service, we requ...