el-js中循环遍历el的集合


遇到问题的代码:

 var score=0;
            for(var i=0;i<${fn:length(tMovie.tComments) };i++){
                 score=${tMovie.tComments[i].userscore} ; 
}
问题:${tMovie.tComments[i].userscore} 取不到任何值
尝试:尝试把i变成0,取到了
总结:el表达式中不能取到js的变量
解决办法:
             var array = new Array();
             <c:forEach items="${tMovie.tComments }" var="tComment"> 
             array.push(${tComment.userscore }); //js中可以使用此标签,将EL表达式中的值push到数组中 
             </c:forEach>    
             for(var i=0;i<array.length;i++)    {
                 score=array[i];
。。。
}

局限性:只能取到el中的基本类型(字符串、数字等),不能取到对象


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM