jsp解决:
<li>商品总金额:<span class="orderStat_bloc"><span class="cr_c21e12">¥<fmt:formatNumber value="${subOrderInfo.cargoAmount + 0.0001}" pattern="#,##0.00"/></span></span></li>
java解决方案:
//商品询价总价
BigDecimal pPrice = new BigDecimal(v.getAgreePrice()).setScale(2, BigDecimal.ROUND_HALF_UP);//保留两位精度四舍五入
//商品成交总价
productTotalAmount = productTotalAmount.add(pPrice.multiply(pCount)).add(new BigDecimal("0.0001")).setScale(2, BigDecimal.ROUND_HALF_UP);//保留两位精度四舍五入遇到类似a=10.50*32.97=346.18499999999999.....约等于34618.50这种数字时,计算a*0.01的时候就会出现=346.18。人民印象中346.1850四舍五入应该是346.19,得到的值却是346.18,会认为是错的,所以此处在页面和java中处理时都加了0.00001