set boolean value into variable using JSTL tags?

前端 未结 5 2078
失恋的感觉
失恋的感觉 2021-02-06 22:30

I am using JSTL tags. i have below code.


Now variable refreshSent has boole

5条回答
  •  粉色の甜心
    2021-02-06 22:54

    It is a String.

    The following JSP code:

    
    
    
    
    
    ${refreshSent} : ${refreshSent['class']}
    ${refreshSent2} : ${refreshSent2['class']}
    ${refreshSent3} : ${refreshSent3['class']}

    Outputs the following in a browser:

    false : class java.lang.String
    false : class java.lang.Boolean
    false : class java.lang.String
    

    But if you use the refreshSent variable in an EL expression where a boolean is expected, it will be converted to a boolean by a call to Boolean.valueOf(String) (according to the JSP Specification).

    So if you use:

    
    

    the value of the test attribute will be set to a boolean false value. The ${refreshSent} expression results in a String, but since the test attribute expects a boolean, a call to Boolean.valueOf("false") is made.

提交回复
热议问题