以下是显示的截图:
图中的数据相加是可以正常显示的,然后下面的两项在一起的时候,就出bug了。
其他的任意两项加都不会出现这种问题。
在Javabean中对数据采用的是BigDecimal的格式
javabean数据处理
public double getSubtotal() {
BigDecimal currPrice = new BigDecimal(book.getCurrPrice() + "");
BigDecimal count = new BigDecimal(quantity + "");
return currPrice.multiply(count).doubleValue();
}
在JS中对从JSP页面中抓取的数据作了先转化为text格式,然后Number(text),进行转换了。
js数据处理
function total(){
var total = 0;
$(":checkbox[name=checkboxBtn][checked=true]").each(function(){
var id = $(this).val();
var text = $("#" + id + "Subtotal").text();
total += Number(text);
});
$("#total").text(total);
}
JSP页面显示:
¥
${cartItem.subtotal }
完全找不到bug点在哪儿?