First, we want to know our own locale,how to display the locale in a JSTL?

<c:out value="${pageContext.request.locale.language}"/>

I'm confused with the jstl tag libs:

I want to format a number to a currency with german style

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
<title>format number</title>
</head>
<body>
<c:set var="val" value="40.52" />
<p> Currency in USA
<fmt:setLocale value="en_US"
scope="session"/>
    <fmt:formatNumber value="${val}" type="currency" />
</p>
<p>Currency in Germany
<fmt:setLocale value="de_DE"
scope="session"/>

    <fmt:formatNumber value="${val}" type="currency"/>
</p>
</body>
</html>

And thats the output:

Currency in USA $40.52
Currency in Germany 40,52 €

I am using fmt:formatNumber to format currency in JSTL, it will display negative currency in ($100) format, if you want to make it display negative currency in negative format instead of ($100).

I would suggest:

<fmt:formatNumber type="currency" pattern="$#,##0.00;-$#,##0.00" value="-10000" />

You can remove '$' from the pattern, if you like.



order example:

<c:set 
var="val"  value="46563746375"/>
<fmt:formatNumber 
value="${val}" 
pattern="###.###E0"/>


If you run the above code you will see the number is formatted as the pattern which is 46.5637E9 .

fmt:formatNumber use locale display negative currency in -$xxx.xx format in JSTL的更多相关文章

  1. <fmt:formatNumber>标签

    <fmt:formatNumber>标签用于格式化数字,百分比,货币. 属性 <fmt:formatNumber>标签有如下属性: 属性 描述 是否必要 默认值 value 要 ...

  2. JSTL fmt:formatNumber 数字、货币格式化

    <fmt:formatNumber value="12.34" pattern="#0.00" /> 12.34 保留小数点后两位数 <fmt ...

  3. jstl <fmt:formatNumber>标签

    标签用于格式化数字,百分比和货币. 如果type属性为百分比或数字,则可以使用多个数字格式属性.maxIntegerDigits和minIntegerDigits属性允许您指定数字的非分数部分的大小. ...

  4. JSTL标签库中fmt标签,日期,数字的格式化

    首先介绍日期的格式化:(不要嫌多哦) JSTL格式化日期(本地化) 类似于数字和货币格式化,本地化环境还会影响生成日期和时间的方式. <%@ page pageEncoding="UT ...

  5. JSP标准标签库(JSTL)--国际化标签库 fmt

    JSTL中使用fmt.tld作为格式化标签库的定义文件 No. 功能分类 标签名称 描述 1 国际化标签 <fmt:setLocale> 设置一个全局的地区代码 2 <fmt:req ...

  6. (2)JSTL的fmt国际化标签库

    format标签库:做国际化格式化,分两类 : 国际化核心标签:<fmt:setLocale>.<fmt:bundle>.<fmt:setBundle>.<f ...

  7. JSTL中fmt标签详解

    一:JSTL格式化标签又称为I18N标签库,主要用来编写国际化的WEB应用,使用此功能可以对一个特定的语言请求做出合适的处理. 例如:中国内地用户将显示简体中文,台湾地区则显示繁体中文,使用I18N格 ...

  8. JSTL——formatNumber标签

    使用场合: <fmt:formatNumber>标签用于格式化数字,百分比,货币 属性: 语法 如果使用pattern属性.这个属性可以让您在对数字编码时包含指定的字符.接下来的表格中列出 ...

  9. jsp中引用的jstl 和fmt标签-详解

    JSTL 核心标签库标签共有13个,功能上分为4类: 1.表达式控制标签:out.set.remove.catch 2.流程控制标签:if.choose.when.otherwise 3.循环标签:f ...

随机推荐

  1. “Hello World!”团队第七次Scrum立会

    "Hello world!"团队召开第七次Scrum立会.博客内容: 1.会议时间 2.会议成员 3.会议地点 4.会议内容 5.Todo list 6.会议照片 7.燃尽图 一. ...

  2. 20172305 2018-2019-1 《Java软件结构与数据结构》第八周学习总结

    20172305 2018-2019-1 <Java软件结构与数据结构>第八周学习总结 教材学习内容总结 本周内容主要为书第十二章内容: 堆(附加属性的二叉树) 完全二叉树 (最小堆)对于 ...

  3. YQCB冲刺周第二天

    YQCB冲刺周第二天 1.实现用户记账的功能 2.实现用户头像的设置 3.实现个人设置的功能 遇到的问题: 记账的分类,数据库存取图片,页面跳转+超链接的使用 团队讨论的照片:             ...

  4. 作业三C++

    作业心得 1.本次作业开始使用C++编写了(面向过程的C++,2333) 2.粗略学习了一下文件输入输出,和项目的创建等(在大佬眼里最基本的操作QAQ,然而我还是有点晕晕的,平时都是ctrl+n新建源 ...

  5. Servlet中常用对象及API类之间的关系

    Servlet最常用的对象: 请求对象:ServletRequest和HttpServletRequest,通过该对象获取来自客户端的请求信息 响应对象:ServletResponse和HttpSer ...

  6. 将 Spring 和 Hibernate 与 WebSphere Application Server 一起使用

    本文摘要 如果您考虑将 Spring 或 Hibernate 与 IBM® WebSphere® Application Server 一起使用,则本文向您阐述了如何配置这些框架,以适用于 WebSp ...

  7. java——线性表接口实现

    线性表是存储顺序牌类的数据时最常用的数据结构. 实现线性表有两种方式.第一种是使用数组存储线性表的元素.数组是动态创建的.超过数组的容量时,创建一个 新的更大的数组,并且将当前数组中的元素复制到新建的 ...

  8. Win10 版本情况 201810

  9. ASP.NET 页面访问控制

    request常用对象和方法: @属性:1.quary string,获取通过URL路径传来的数据 2.Form,获取通过表单提交传输的数据 3.servervariables,获取Web服务器变量的 ...

  10. 第102天:CSS3实现立方体旋转

    CSS3实现立方体旋转 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu ...