JSTL< c:set>身体内容确切规格 [英] JSTL <c:set> body content exact specification

查看:63
本文介绍了JSTL< c:set>身体内容确切规格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以建议如何解释<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[],其值分别为OneTwoThree.

will result ${realMovieArray} being a String[] with values of One, Two and Three.

这篇关于JSTL&lt; c:set&gt;身体内容确切规格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆