Spring4-2-bean Configuring the -6-spring expression language Spel

Source: Internet
Author: User

Spring expression Language (Spel): is a powerful expression language that supports run-time querying and manipulating object graphs .
Syntax similar to El:spel using #{...} as delimiters, all characters in the large frame number will be considered spel
Spel provides the convenience for dynamic assignment of bean properties
The Spel can be implemented by:

      • To reference a bean by its ID
      • Calling methods and referencing properties in an object
      • Evaluate the value of an expression
      • Matching of regular expressions
Representation of a literal

  integer : <property name= "Count" value= "#{5}"/>
  decimals : <property name= "Frequency" value= "#{89.7}"/>
  scientific notation : <property name= "Capacity" value= "#{1e4}"/>
  string can use single or double quotation marks as the bounding symbol of a string: <property name= "name" value= "#{' Chuck '}"/> or <property name= ' name ' Value= ' #{"Chuck"} '/>
  Boolean: <property name= "Enabled" Value= "#{false}"/>

Note: It is not very significant to use Spel if it is only a literal value. You can assign values directly in value.

Reference beans, properties, and methods refer to other objects:

  

Referencing properties of other objects (Spel exclusive)

  

Call other methods and also chain-operated (Spel exclusive)

  

Calling a static method or static property

By calling a static method of a class by T (), it returns a class Object and then invokes the appropriate method or property:
  

Spel supported arithmetic notation arithmetic operators: +,-, *,/,%, ^:

  

The plus sign can also be used as a string connection: comparison operator: <,;, = =, <=, >=, lt, GT, eq, le, ge

  

  

Logical operation symbols: and, or, not, |

  

If-else operator:?: (Ternary),?: (Elvis)

  

Variants of the If-else

  

Regular expression: Matches

Spring4-2-bean Configuring the -6-spring expression language Spel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.