gpt4 book ai didi

java - JSTL formatNumber 显示空字符串

转载 作者:行者123 更新时间:2023-11-30 03:57:46 25 4
gpt4 key购买 nike

在jsp中我有这个:

<h3>Order total: <fmt:formatNumber type="NUMBER" value="${order.total}"/></h3>

打开页面时的html:

<h3>Order total: <fmt:formatNumber value="20.0" type="NUMBER"/></h3>

但我看不到数字,只看到订单总数:

完整的jsp:

<html xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:spring="http://www.springframework.org/tags"
xmlns:form="http://www.springframework.org/tags/form"
xmlns:fmt="http://java.sun.com/jstl/format">

<jsp:output omit-xml-declaration="yes"/>
<jsp:directive.page contentType="text/html;charset=UTF-8" />

<head><title>Spizza</title></head>
<body>
<h2>Your order</h2>

<h3>Deliver to:</h3>
<b>${order.customer.name}</b><br/>
<b>${order.customer.address}</b><br/>
<b>${order.customer.city}, ${order.customer.state}
${order.customer.zipCode}</b><br/>
<b>${order.customer.phoneNumber}</b><br/>
<hr/>
<h3>Order total: <fmt:formatNumber type="NUMBER"
value="${order.total}"/></h3>
<hr/>
<h3>Pizzas:</h3>

<c:if test="${fn:length(order.pizzas) eq 0}">
<b>No pizzas in this order.</b>
</c:if>

<br/>
<c:forEach items="${order.pizzas}" var="pizza">
<li>${pizza.size} :
<c:forEach items="${pizza.toppings}" var="topping">
<c:out value="${topping}" />,
</c:forEach>
</li>
</c:forEach>

<form:form>
<input type="hidden" name="_flowExecutionKey"
value="${flowExecutionKey}"/>
<input type="submit" name="_eventId_createPizza"
value="Create Pizza" />
<c:if test="${fn:length(order.pizzas) gt 0}">
<input type="submit" name="_eventId_checkout"
value="Checkout" />
</c:if>
<input type="submit" name="_eventId_cancel"
value="Cancel" />
</form:form>

</body>
</html>

最佳答案

The documentation说:

Standard Syntax:

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

XML Syntax:

 <anyxmlelement xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" />

关于java - JSTL formatNumber 显示空字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22696988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com