Inkfish translation, do not reprint the commercial nature, reproduced please indicate the source (http://blog.csdn.net/inkfish). This article is I study juel at the same time, to the original website carries on the simple translation, the original website address: http://juel.sourceforge.net/guide/start.html.
Quick Start
The Juel release contains some of the following jar files: (Source: Http://blog.csdn.net/inkfish)
1.juel-api-2.2.x.jar--contains some classes under the Javax.el package
2.juel-impl-2.2.x.jar--contains De.odysseus.el implementation classes
3.juel-spi-2.2.x.jar--contains definitions of meta-inf/service/javax.el.expressionfactory service provisioning resources (if you have multiple implementations of El in your classpath, And you want to use the Juel implementation, then you need to call Expressionfactory.newinstance ())
The 4.juel-2.2.x.jar--contains classes under the Java.el package and contains implementation classes under De.odysseus.el, as well as a service Provider Interface (SPI)
That is to say: Juel-2.2.x.jar = Juel-api-2.2.x.jar + Juel-impl-2.2.x.jar + Juel-spi-2.2.x.jar. (Source: Http://blog.csdn.net/inkfish)
Here's what you need to use El in your application (assuming you've put Juel-2.2.x.jar under Classpath and imported javax.el.*): (Source: Http://blog.csdn.net/inkfish)
1. Factory and Context (Source: http://blog.csdn.net/inkfish)
The implementation of the Expressionfactory class is De.odysseus.el.ExpressionFactoryImpl expressionfactory factory = new De.odysseus.el.ExpressionFactoryImpl (); De.odysseus.el.util provides package provides instantly available subclasses Elcontext de.odysseus.el.util.SimpleContext context = new De.odysseus.el.util.SimpleContext ();
2. Functions and Variables (source: http://blog.csdn.net/inkfish)
Set the map function math:max (int, int) using Java.lang.Math.max (int, int) context.setfunction ("Math", "Max", Math.class.getMethod (" Max ", Int.class, Int.class)); The map variable foo is set to 0 context.setvariable ("foo", Factory.createvalueexpression (0, Int.class));
3. Resolution and Evaluation (Source: Http://blog.csdn.net/inkfish)
Parse expression valueexpression e = factory.createvalueexpression (Context, "${math:max (Foo,bar)}", Int.class); Setting the top-level property "bar" value is 1 factory.createvalueexpression (context, "${bar}", Int.class). SetValue (context, 1);