gpt4 book ai didi

arrays - JSTL body content exact specification

转载 作者:行者123 更新时间:2023-12-01 23:16:10 24 4
gpt4 key购买 nike

有人可以建议如何解释 <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"}

什么是 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 类型没有差异。在所有 情况下它只是String

即使您使用 EL 将非字符串类型设置为 c:set 的主体,例如

<c:set var="foo">${bean.someInteger}</c:set>

它无论如何都会被 String#valueOf() 转换成 String

只有当您之后处理变量时,可能才会有所不同,这取决于您如何处理它。例如,

<c:set var="movieList">One,Two,Three</c:set>
<c:set var="realMovieArray" value="${fn:split(movieList, ',')}" />

将导致 ${realMovieArray} 成为 String[],其值为 OneTwo三个

关于arrays - JSTL <c :set> body content exact specification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6820666/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com