Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
带水的鱼儿
spring-framework
提交
01e50fb6
S
spring-framework
项目概览
带水的鱼儿
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
01e50fb6
编写于
4月 22, 2021
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish SpEL chapter
上级
6c3a0a90
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
35 deletion
+37
-35
src/docs/asciidoc/core/core-expressions.adoc
src/docs/asciidoc/core/core-expressions.adoc
+37
-35
未找到文件。
src/docs/asciidoc/core/core-expressions.adoc
浏览文件 @
01e50fb6
...
...
@@ -517,7 +517,7 @@ kinds of expression cannot be compiled at the moment:
*
Expressions
using
custom
resolvers
or
accessors
*
Expressions
using
selection
or
projection
More
types
of
expression
will
be
compilable
in
the
future
.
More
types
of
expression
s
will
be
compilable
in
the
future
.
...
...
@@ -589,7 +589,7 @@ You can also refer to other bean properties by name, as the following example sh
To
specify
a
default
value
,
you
can
place
the
`@
Value
`
annotation
on
fields
,
methods
,
and
method
or
constructor
parameters
.
The
following
example
sets
the
default
value
of
a
field
variable
:
The
following
example
sets
the
default
value
of
a
field
:
[
source
,
java
,
indent
=
0
,
subs
=
"verbatim,quotes"
,
role
=
"primary"
]
.
Java
...
...
@@ -788,7 +788,7 @@ using a literal on one side of a logical comparison operator.
----
Numbers
support
the
use
of
the
negative
sign
,
exponential
notation
,
and
decimal
points
.
By
default
,
real
numbers
are
parsed
by
using
Double
.
parseDouble
()
.
By
default
,
real
numbers
are
parsed
by
using
`
Double
.
parseDouble
()`
.
...
...
@@ -796,10 +796,10 @@ By default, real numbers are parsed by using Double.parseDouble().
===
Properties
,
Arrays
,
Lists
,
Maps
,
and
Indexers
Navigating
with
property
references
is
easy
.
To
do
so
,
use
a
period
to
indicate
a
nested
property
value
.
The
instances
of
the
`
Inventor
`
class
,
`
pupin
`
and
`
tesla
`,
were
populated
with
data
listed
in
the
<<
expressions
-
example
-
classes
,
Classes
used
in
the
examples
>>
section
.
To
navigate
"`down`"
and
get
Tesla
's year of birth and Pupin'
s
city
of
birth
,
we
use
the
following
expressions
:
property
value
.
The
instances
of
the
`
Inventor
`
class
,
`
pupin
`
and
`
tesla
`,
were
populated
with
data
listed
in
the
<<
expressions
-
example
-
classes
,
Classes
used
in
the
examples
>>
section
.
To
navigate
"down"
the
object
graph
and
get
Tesla
's year of birth and
Pupin'
s
city
of
birth
,
we
use
the
following
expressions
:
[
source
,
java
,
indent
=
0
,
subs
=
"verbatim,quotes"
,
role
=
"primary"
]
.
Java
...
...
@@ -939,7 +939,7 @@ You can directly express lists in an expression by using `{}` notation.
----
`{}`
by
itself
means
an
empty
list
.
For
performance
reasons
,
if
the
list
is
itself
entirely
composed
of
fixed
literals
,
a
constant
list
is
created
to
represent
the
entirely
composed
of
fixed
literals
,
a
constant
list
is
created
to
represent
the
expression
(
rather
than
building
a
new
list
on
each
evaluation
).
...
...
@@ -967,10 +967,11 @@ following example shows how to do so:
val
mapOfMaps
=
parser
.
parseExpression
(
"{name:{first:'Nikola',last:'Tesla'},dob:{day:10,month:'July',year:1856}}"
).
getValue
(
context
)
as
Map
<*,
*>
----
`{:}`
by
itself
means
an
empty
map
.
For
performance
reasons
,
if
the
map
is
itself
composed
of
fixed
literals
or
other
nested
constant
structures
(
lists
or
maps
),
a
constant
map
is
created
to
represent
the
expression
(
rather
than
building
a
new
map
on
each
evaluation
).
Quoting
of
the
map
keys
is
optional
.
The
examples
above
do
not
use
quoted
keys
.
`{:}`
by
itself
means
an
empty
map
.
For
performance
reasons
,
if
the
map
is
itself
composed
of
fixed
literals
or
other
nested
constant
structures
(
lists
or
maps
),
a
constant
map
is
created
to
represent
the
expression
(
rather
than
building
a
new
map
on
each
evaluation
).
Quoting
of
the
map
keys
is
optional
(
unless
the
key
contains
a
period
(`.`)).
The
examples
above
do
not
use
quoted
keys
.
...
...
@@ -1003,8 +1004,7 @@ to have the array populated at construction time. The following example shows ho
val
numbers3
=
parser
.
parseExpression
(
"new int[4][5]"
).
getValue
(
context
)
as
Array
<
IntArray
>
----
You
cannot
currently
supply
an
initializer
when
you
construct
multi
-
dimensional
array
.
You
cannot
currently
supply
an
initializer
when
you
construct
a
multi
-
dimensional
array
.
...
...
@@ -1105,7 +1105,7 @@ expression-based `matches` operator. The following listing shows examples of bot
boolean
trueValue
=
parser
.
parseExpression
(
"'5.00' matches '^-?
\\
d+(
\\
.
\\
d{2})?$'"
).
getValue
(
Boolean
.
class
);
//
evaluates
to
false
//
evaluates
to
false
boolean
falseValue
=
parser
.
parseExpression
(
"'5.0067' matches '^-?
\\
d+(
\\
.
\\
d{2})?$'"
).
getValue
(
Boolean
.
class
);
----
...
...
@@ -1120,14 +1120,14 @@ expression-based `matches` operator. The following listing shows examples of bot
val
trueValue
=
parser
.
parseExpression
(
"'5.00' matches '^-?
\\
d+(
\\
.
\\
d{2})?$'"
).
getValue
(
Boolean
::
class
.
java
)
//
evaluates
to
false
//
evaluates
to
false
val
falseValue
=
parser
.
parseExpression
(
"'5.0067' matches '^-?
\\
d+(
\\
.
\\
d{2})?$'"
).
getValue
(
Boolean
::
class
.
java
)
----
CAUTION
:
Be
careful
with
primitive
types
,
as
they
are
immediately
boxed
up
to
the
wrapper
type
,
so
`
1
instanceof
T
(
int
)`
evaluates
to
`
false
`
while
`
1
instanceof
T
(
Integer
)`
evaluates
to
`
true
`,
as
expected
.
CAUTION
:
Be
careful
with
primitive
types
,
as
they
are
immediately
boxed
up
to
the
ir
wrapper
types
.
For
example
,
`
1
instanceof
T
(
int
)`
evaluates
to
`
false
`,
while
`
1
instanceof
T
(
Integer
)`
evaluates
to
`
true
`,
as
expected
.
Each
symbolic
operator
can
also
be
specified
as
a
purely
alphabetic
equivalent
.
This
avoids
problems
where
the
symbols
used
have
special
meaning
for
the
document
type
in
...
...
@@ -1155,7 +1155,7 @@ SpEL supports the following logical operators:
*
`
or
`
(`||`)
*
`
not
`
(`
!`)
The
following
example
shows
how
to
use
the
logical
operators
The
following
example
shows
how
to
use
the
logical
operators
:
[
source
,
java
,
indent
=
0
,
subs
=
"verbatim,quotes"
,
role
=
"primary"
]
.
Java
...
...
@@ -1222,10 +1222,11 @@ The following example shows how to use the logical operators
[[
expressions
-
operators
-
mathematical
]]
====
Mathematical
Operators
You
can
use
the
addition
operator
on
both
numbers
and
strings
.
You
can
use
the
subtraction
,
multiplication
,
and
division
operators
only
on
numbers
.
You
can
also
use
the
modulus
(%)
and
exponential
power
(^)
operators
.
Standard
operator
precedence
is
enforced
.
The
following
example
shows
the
mathematical
operators
in
use
:
You
can
use
the
addition
operator
(`+`)
on
both
numbers
and
strings
.
You
can
use
the
subtraction
(`-`),
multiplication
(`*`),
and
division
(`/`)
operators
only
on
numbers
.
You
can
also
use
the
modulus
(`%`)
and
exponential
power
(`^`)
operators
on
numbers
.
Standard
operator
precedence
is
enforced
.
The
following
example
shows
the
mathematical
operators
in
use
:
[
source
,
java
,
indent
=
0
,
subs
=
"verbatim,quotes"
,
role
=
"primary"
]
.
Java
...
...
@@ -1296,9 +1297,9 @@ following example shows the mathematical operators in use:
[[
expressions
-
assignment
]]
====
The
Assignment
Operator
To
set
ting
a
property
,
use
the
assignment
operator
(`=`).
This
is
typically
done
within
a
call
to
`
setValue
`
but
can
also
be
done
inside
a
call
to
`
getValue
`.
The
following
listing
shows
both
ways
to
use
the
assignment
operator
:
To
set
a
property
,
use
the
assignment
operator
(`=`).
This
is
typically
done
within
a
call
to
`
setValue
`
but
can
also
be
done
inside
a
call
to
`
getValue
`.
The
following
listing
shows
both
ways
to
use
the
assignment
operator
:
[
source
,
java
,
indent
=
0
,
subs
=
"verbatim,quotes"
,
role
=
"primary"
]
.
Java
...
...
@@ -1333,9 +1334,9 @@ You can use the special `T` operator to specify an instance of `java.lang.Class`
type
).
Static
methods
are
invoked
by
using
this
operator
as
well
.
The
`
StandardEvaluationContext
`
uses
a
`
TypeLocator
`
to
find
types
,
and
the
`
StandardTypeLocator
`
(
which
can
be
replaced
)
is
built
with
an
understanding
of
the
`
java
.
lang
`
package
.
This
means
that
`
T
()`
references
to
types
within
`
java
.
lang
`
do
not
need
to
be
fully
qualified
,
but
all
other
type
references
must
be
.
The
following
example
shows
how
to
use
the
`
T
`
operator
:
`
java
.
lang
`
package
.
This
means
that
`
T
()`
references
to
types
within
the
`
java
.
lang
`
package
do
not
need
to
be
fully
qualified
,
but
all
other
type
references
must
be
.
The
following
example
shows
how
to
use
the
`
T
`
operator
:
[
source
,
java
,
indent
=
0
,
subs
=
"verbatim,quotes"
,
role
=
"primary"
]
.
Java
...
...
@@ -1365,9 +1366,10 @@ to use the `T` operator:
[[
expressions
-
constructors
]]
===
Constructors
You
can
invoke
constructors
by
using
the
`
new
`
operator
.
You
should
use
the
fully
qualified
class
name
for
all
but
the
types
located
in
the
core
package
`
java
.
lang
`.
The
following
example
shows
how
to
use
the
`
new
`
operator
to
invoke
constructors
:
You
can
invoke
constructors
by
using
the
`
new
`
operator
.
You
should
use
the
fully
qualified
class
name
for
all
types
except
those
located
in
the
`
java
.
lang
`
package
(`
Integer
`,
`
Float
`,
`
String
`,
and
so
on
).
The
following
example
shows
how
to
use
the
`
new
`
operator
to
invoke
constructors
:
[
source
,
java
,
indent
=
0
,
subs
=
"verbatim,quotes"
,
role
=
"primary"
]
.
Java
...
...
@@ -1376,7 +1378,7 @@ example shows how to use the `new` operator to invoke constructors:
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')"
)
.
getValue
(
Inventor
.
class
);
//
create
new
inventor
instance
within
add
method
of
List
//
create
new
Inventor
instance
within
the
add
()
method
of
List
p
.
parseExpression
(
"Members.add(new org.spring.samples.spel.inventor.Inventor(
'Albert Einstein', 'German'))"
).
getValue
(
societyContext
);
...
...
@@ -1388,7 +1390,7 @@ example shows how to use the `new` operator to invoke constructors:
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')"
)
.
getValue
(
Inventor
::
class
.
java
)
//
create
new
inventor
instance
within
add
method
of
List
//
create
new
Inventor
instance
within
the
add
()
method
of
List
p
.
parseExpression
(
"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))"
)
.
getValue
(
societyContext
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录