JSTL常用方法整理

xiaoxiao2022-06-14  33

//TODO:等待编辑 1.常用方法: <c:set var="name" value="${object.name}"/><c:if test="{empty name}">-</c:if><c:choose><c:when test="${object.grade eq '100'}">A</c:when><c:otherwise>B</c:otherwise></c:choose><c:forEach var="order" items="${orderlist}">${order.id}</c:forEach> 再进一步: <c:set var="name" value="<%=product.name%>"/><c:if test="{param.price eq '50'}"> selected="selected" </c:if><c:choose><c:when test="${object.grade eq '100'}">A</c:when><c:when test="${object.grade gt '90'}">B</c:when>...<c:otherwise>E</c:otherwise></c:choose><c:forEach begin="0" end="5" var="order" items="${orderlist}" varStatus="s" step="2">id:${order.id}index:${s.index}count:${s.count}first:${s.first}last:${s.last}步长:2</c:forEach> 2.fmt:formatDate <fmt:formateDate value="${order.createDate}" patten="yyyy-MM-dd"/> 3.fmt:formatNumber <fmt:formatNumber value="12" type="currency" pattern="$.00"/> : $12.00<fmt:formatNumber value="12" type="currency" pattern="$.0#"/> : $12.0<fmt:formatNumber value="1234567890" type="currency"/> : $1,234,567,890.00<fmt:formatNumber value="123456.7891" pattern="#,#00.0#"/> : 123,456.79<fmt:formatNumber value="123456.7" pattern="#,#00.0#"/> : 123,456.7<fmt:formatNumber value="123456.7" pattern="#,#00.00#"/> : 123,456.70<fmt:formatNumber value="12" type="percent" /> : 1,200% [quote="符号说明"]0 一个数位 # 一个数位,前导零和追尾零不显示 . 小数点分割位置 , 组分隔符的位置 - 负数前缀 % 用100乘,并显示百分号 [/quote] [quote="其他说明"]数字的取舍规则是 4舍6入5奇偶 [/quote] java中可同样处理:Double d = 123456.7891;DecimalFormat df = new DecimalFormat("#,#00.0#");String fmt =df.format(d);得到:123,456.79 4.fn:
转载请注明原文地址: https://www.6miu.com/read-4936617.html

最新回复(0)