Expression Language 3.0 API detailed explanation

Detailed explanation of the expression language in the Java class library 3.0 API Java expression language is a mechanism for dynamic computing expression in the Java program.Java Expression Language (EL) is introduced by the Java server page (JSP) specification. It aims to improve the availability of JSP technology by simplifying the development and management of the page.Expression Language 3.0 API is an updated version introduced in Java Ee 7, providing developers with a stronger and more flexible expression language function. The main features of Expression Language 3.0 API include: 1. Support calculation expression when runtime: EL 3.0 allows dynamic computing expressions during runtime, which enables developers to generate dynamic content according to the state of the application and needs. 2. Introduced Lambda expression: EL 3.0 introduced LAMBDA expression, which is an important language function introduced in Java 8.Lambda expressions allow developers to write function code in a more concise and clearer way. 3. Support collection operation: EL 3.0 API provides some new functions for processing collection operations.These functions can be used to filter, map and aggregate operations for sets. 4. Support method call: Through EL 3.0, developers can call the object method, and can also pass parameters.This allows the Java method directly in the expression. Here are some examples of Java code for Java code using Expression Language 3.0 API: 1. Dynamic calculation expression: ELProcessor elp = new ELProcessor(); Object result = elp.eval ("3 + 4"); // Calculate expression 3 + 4 System.out.println (result); // Output results 7 2. Lambda expression: ELProcessor elp = new ELProcessor(); Elp.setLambdaresolver (New MyLambdaresolver ()); // Set lambda expression parser Object result = elp.eval ("()-> 'hello, world!'"); // Use lambda expression System.out.println (result); // output results hello, world! 3. Collection operation: ELProcessor elp = new ELProcessor(); List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5); elp.definebean ("numbers", numbers); // Define a collection called Numbers Object result = elp.eval ("numbers.stream (). Filter (n-> n % 2 == 0) .Collect (colorctors.tolist ())"); // System.out.println (result); // Output results [2, 4] 4. Method call: ELProcessor elp = new ELProcessor(); String text = "Hello, World!"; elp.definebean ("text", text); // Define a string called Text Object result = elp.eval ("text.substring (0, 5)"); // call the substring method of the string System.out.println (result); // output results hello Expression Language 3.0 API provides developers with a convenient and powerful way to dynamically calculate the expression in the Java program.By using Expression Language, developers can write more flexible and maintenance code and improve the development efficiency of the application.