JSTL< c:set>身体内容确切规格 [英] JSTL <c:set> body content exact specification
问题描述
有人可以建议如何解释<c:set>
身体吗?
can someone suggest how possible to interpret <c:set>
body?
-
<c:set var="movieList">One,Two,Three</c:set>
<c:set var="movieList">"One","Two","Three"</c:set>
在第一种情况下movieList
是字符串,在第二种情况下是数组{"One", "Two", "Three"}
in the first case movieList
is a string and in the second it is an array {"One", "Two", "Three"}
这些示例中的movieList
是什么:
-
<c:set var="movieList">"On"e","Tw"o","Thr"ee"</c:set>
<c:set var="movieList">"On\"e","Tw"o","Thr\"ee"</c:set>
推荐答案
c:set
主体的解释Java类型没有没有差异.在 all 情况下,仅是String
.
There's no difference in the interpreted Java type of the c:set
's body. It are in all cases just String
.
即使使用EL之类的将非字符串类型设置为c:set
的主体,例如
Even when you set a non-String type as c:set
's body using EL such as
<c:set var="foo">${bean.someInteger}</c:set>
无论如何,它将由String#valueOf()
转换为String
.
it'll be converted to String
anyway by String#valueOf()
.
仅在以后处理变量时,可能有所不同,具体取决于处理方式.例如,
Only when you process the variable afterwards, there may be difference, depending on how you processed it. For example,
<c:set var="movieList">One,Two,Three</c:set>
<c:set var="realMovieArray" value="${fn:split(movieList, ',')}" />
将导致${realMovieArray}
为String[]
,其值分别为One
,Two
和Three
.
will result ${realMovieArray}
being a String[]
with values of One
, Two
and Three
.
这篇关于JSTL< c:set>身体内容确切规格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!