簡體   English   中英

jstl c:set不適用於jsp文件中的js代碼

[英]jstl c:set is not working on js code in jsp file

我有來自服務的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

我已經通過使用if條件與js解決了它:

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

感謝大家

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM