Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSTL Format Number

807589Dec 18 2008 — edited Dec 18 2008
Hi guys,

I am changing an already developed Spring application.. All I need to do is to put a format the float number to two decimal digits...I am trying to use JSTL formatNumber, but somehow its not picking the data in the bean.. any help would be very appreciable.. here is a little snippet of the code
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>

<c:if test="${requestScope.data != null}">
		<table id='dataArea'>
			<tr>
				<td class='tdGrey bleft btop' style='width: 160px;'><spring:message
					code="chapter_three.maximum_daily_rate.label" />:</td>
				<td class='btop'>${requestScope.data.maxDailyRate}</td>

			</tr>
			<tr>
				<td class='tdGrey bleft btop'><spring:message
					code="chapter_three.regular_open_hour_per_week.label" />:</td>
				<td class='btop'>${requestScope.data.regularOpenHourPerWeek}</td>
			</tr>
....
*${requestScope.data.maxDailyRate}* correctly prints the floating number, say 50.0

if I change this to

*<fmt:formatNumber maxFractionDigits="2" minFractionDigits="2" value="${requestScope.data.maxDailyRate}"></fmt:formatNumber>* that somehow doesn't work, although I dont get any exception.. when I say doesn't work, I see no change in the page.

I am using Tomcat 5.5.23 and Java 1.6..

Any ideas, Please

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 15 2009
Added on Dec 18 2008
3 comments
524 views