[英]javascript variable and scriptlet value is not matching
我正在嘗試將 javascript 變量值與從 jsp 中的 scriptlet 中獲取的值進行匹配,但即使值相同我也沒有得到正確的結果。
var a = 1;
console.log(a == <%=Constants.SOME_CONSTANT_VALUE%>);
這里 Constants.SOME_CONSTANT_VALUE 的值是 "1" [String type] 但我得到的控制台輸出為 false。
試試 console.log(a == "<%=Constants.SOME_CONSTANT_VALUE%>");
使用parseInt
並進行如下比較:
console.log(a == parseInt(<%=Constants.SOME_CONSTANT_VALUE%>));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.