jstl c:set不适用于jsp文件中的js代码

时间:2018-07-05 11:23:58

标签: java jsp jstl jstl-functions

我有来自服务的JSON。我要按JSON值附加html块,并且必须检查一些值以进行适当的显示。 我正在尝试设置DiscountValue变量,但不能与js变量一起使用。我该怎么解决?

  if (data!="")
                {
                    $.each(data,function(index,element){
                        var intDiscount=parseInt(10);
                        console.log("intDiscount::"+intDiscount);

                        var strIndex='';
                        strIndex+='<div class="card">';
                        strIndex+='<c:set var="discountValue" value="'+intDiscount+'"/>';
                        console.log("${discountValue}");
...
...
...
...
                 }
                 $('#visilabs-FavouriteCategoryTopSeller').append(strIndex);

控制台日志:

intDiscount::10
0

1 个答案:

答案 0 :(得分:0)

我已经通过在js中使用if条件解决了这个问题:

if(element.discount>0){
                            strIndex+=                      '           <span class="label label-danger discount">'+'%&nbsp;'+intDiscount+'</span>';
                        }

谢谢大家