jsp页面中格式化为小数点两位

      <td align="center">&nbsp;
           <%
            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>

 

posted @ 2016-01-25 14:15  星辰之力  阅读(1949)  评论(0编辑  收藏  举报