JSTL Core fmt parseNumber Tag

JSTL Core fmt parseNumber Tag

JSTL Core fmt:parseNumber Tag

Below is standard syntax to include in your JSP page:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

JSP example:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <h2>fmt:parseNumber example</h2>
    <c:set var="current" value="123456.87654" scope="request" />

    <h3>Parsed number with different style</h3>

    <fmt:parseNumber var="current" type="number" value="${current}" />

    <p>
        Parsed number:
        <c:out value="${current}" />
    </p>

    <fmt:parseNumber var="current" integerOnly="true" type="number"
        value="${current}" />
    <p>
        Parsed number:
        <c:out value="${current}" />
    </p>

</body>
</html>

Output:

JSTL Core fmt parseNumber Tag

 

 

download Download Project: jstl-1.2

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *