jsp el表达式中float转成整型怎么做?

来源:百度知道 编辑:UC知道 时间:2024/06/14 08:30:03
${(store.maxNum-store.reportNum)/2 }
这个el表达式算出来是float型的 有一位小数,怎么转为整型呀?

使用JSTL中的fmt标签库。
<%@ page contentType="text/html; charset=gb2312"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:set var="a" value="10"/>
<c:set var="b" value="3"/>
<fmt:formatNumber var="c" value="${a / b}" pattern="#"/>
${c}