language expression
Welcome
to the English lessons on language expression
Expression Language
This chapter
introduces the Expression Language (also referred to as the EL), which
provides an important mechanism for enabling the presentation layer (web pages)
to communicate with the application logic (managed beans). The EL is used by
both JavaServer Faces technology and JavaServer Pages (JSP) technology. The EL
represents a union of the expression languages offered by JavaServer Faces
technology and JSP technology.
While there are several other Java expression
languages available, OGNL, MVEL, and JBoss EL, to name a few, the Spring
Expression Language was created to provide the Spring community with a single
well supported expression language that can be used across all the products in
the Spring portfolio. Its language features are driven by the requirements of
the projects in the Spring portfolio, including tooling requirements for code
completion support within the eclipse based Spring Tool Suite. That said, SpEL
is based on a technology agnostic API allowing other expression language implementations
to be integrated should the need arise.While SpEL serves as the foundation for expression evaluation within the Spring portfolio, it is not directly tied to Spring and can be used independently. In order to be self contained, many of the examples in this chapter use SpEL as if it were an independent expression language. This requires creating a few bootstrapping infrastructure classes such as the parser. Most Spring users will not need to deal with this infrastructure and will instead only author expression strings for evaluation. An example of this typical use is the integration of SpEL into creating XML or annotated based bean definitions as shown in the section Expression support for defining bean definitions.
This chapter covers the features of the expression language, its API, and its language syntax. In several places an Inventor and Inventor’s Society class are used as the target objects for expression evaluation. These class declarations and the data used to populate them are listed at the end of the chapter.
The ExpressionLanguage
Component
The ExpressionLanguage
component provides an engine that can compile and evaluate expressions. An
expression is a one-liner that returns a value (mostly, but not limited to,
Booleans).
The purpose of the component is to allow
users to use expressions inside configuration for more complex logic. For some
examples, the Symfony2 Framework uses expressions in security, for validation
rules and in route matching.Besides using the component in the framework itself, the ExpressionLanguage component is a perfect candidate for the foundation of a business rule engine. The idea is to let the webmaster of a website configure things in a dynamic way without using PHP and without introducing security problems:
Expressions can be
seen as a very restricted PHP sandbox and are immune to external injections as
you must explicitly declare which variables are available in an expression.
Usage
The
ExpressionLanguage component can compile and evaluate expressions. Expressions
are one-liners that often return a Boolean, which can be used by the code
executing the expression in an
if statement. A simple example of an expression is 1 + 2.
You can also use more complicated expressions, such as someArray[3].someMethod('bar')
The component provides 2 ways to work
with expressions:
- evaluation:
the expression is evaluated without being compiled to PHP;
- compile:
the expression is compiled to PHP, so it can be cached and evaluated.
Expression Syntax
Passing in Variables
You can also pass
variables into the expression, which can be of any valid PHP type (including
objects):
This will print
"Honeycrisp". For more information, see the The Expression Syntax
entry, especially Working with Objects and Working with Arrays.
Caching
|
Language Expressions in context
|
|
|
Sheila :
|
Oh, no ! It's raining cats and
dogs. I don't think Shirley will turn up for this meeting.
|
|
Mina :
|
But she's given us her word.
And you know we can always count on Shirley to be present.
|
|
Sheila :
|
I hope you are right. We need
to put our heads together to plan for the trip.
|
|
Mina :
|
Look, here comes Shirley. What did
I tell you ?
Expression
A.
The
action of making known one's thoughts or feelings.
‘ the prisoners developed a dialect as an
everyday means of expression’
‘she accepted his expressions of sympathy
B.
A look
on someone's face that conveys a particular emotion.
‘a sad expression’
C.
A word
or phrase, especially an idiomatic one, used to convey an idea.
‘we have an expression, ‘You don't get owt
for nowt.’’
D.
The
production of something by pressing it out.
‘essential oils obtained by distillation
or expression’
E.
Genetics
The appearance in a phenotype of a characteristic or effect attributed to a particular gene.
expression of the TAT gene is restricted to
the parenchymal cells
Thank you for reading me English lessons on
language expression that I created
|








