jsp页面中格式化为小数点两位
<td align="center"> <% String avgnum = ""; if(request.getAttribute("avgnum") != null && !"".equals(request.getAttribute("avgnum"))){ double t = Double.parseDouble((String)request.getAttribute("avgnum")); java.text.DecimalFormat df = new java.text.DecimalFormat("#.00"); avgnum = df.format(t); } %> <%=avgnum %> </td>