Format number with JSTL and no rounding
问题 I need to format number using <fmt:formatNumber/> jstl tag. The output should be restricted to 3 places after the decimal point, but rounding isn't allowed, so using the attribute maxFractionDigits="3" isn't appropriate, cause it rounds the number. Do you have any suggestions? 回答1: You could subtract 0.0005 from the number before formatting it. That way the rounding will be equivalent to truncating the original number to 3 decimal places. <fmt:formatNumber value="${myNumber - 0.0005}"