JSTL body content exact specification

前端 未结 2 603
广开言路
广开言路 2021-01-20 20:04

can someone suggest how possible to interpret body?

  • One,Two,Three

相关标签:
2条回答
  • 2021-01-20 20:41

    There's no difference in the interpreted Java type of the c:set's body. It are in all cases just String.

    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>
    

    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, ',')}" />
    

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

    0 讨论(0)
  • 2021-01-20 20:55
    <c:set var="alphabet">A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z</c:set>
    
    <c:forTokens items="${alphabet}" delims="," var="letter">
        ${letter}
    </c:forTokens>
    
    0 讨论(0)
提交回复
热议问题