In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "the usage of Spring expression language SpEL". In daily operation, I believe that many people have doubts about the usage of Spring expression language SpEL. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "the usage of Spring expression language SpEL". Next, please follow the editor to study!
Using the id of Bean to reference the calling method of Bean and the value regular expression matching of the evaluation expression of the property of the reference object
A literal representation:
Integer: # {5} decimal: # {3.45} Scientific Counting: # [1e4] string: delimiters of early flavor strings that can use single or double quotation marks: # {'tom'}, # {"tom"} Boolean value: # {false}
Operational symbols supported by SpEL: +-* /% ^
< >= lt gt eq le ge and or not | (?:) if-else regular expression, etc.
Call static properties and methods: through T ()
The following code ignores the getter, setter, and to_string methods in the class.
Car.java
Package com.gong.spring.beans.spel;public class Car {public Car () {} public Car (String name) {this.name = name;} private String name; / / Tire perimeter private double tyrePerimeter; private double price;}
Address.java
Package com.gong.spring.beans.spel;public class Address {private String city; private String street;}
Student.java
Package com.gong.spring.beans.spel;public class Student {private String name; private int age; private double score; private String city; private String info; private Car car; private Address address;}
Beans-spel.xml
Main.java
Package com.gong.spring.beans.spel;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class Main {public static void main (String [] args) {/ / 1. Create the IOC container object of spring ApplicationContext ctx = new ClassPathXmlApplicationContext ("beans-spel.xml"); / / 2. Get Bean instance Student student = (Student) ctx.getBean ("student") from the container; System.out.println (student.toString ());}}
At this point, the study of "the use of the Spring expression language SpEL" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.