Question

I have the following textfield which shows the value 50,000,000 of the variable as 5.0E7,

I know I can format it using fmt tag, but the problem is that I am using Struts2 iterator and I can not use the fmt inside the textfield.

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

<s:iterator value="products.items" var="item" status="cursor">
<s:textfield id="price" name="products.items[%{#cursor.index}].price" 
  value="<fmt:formatNumber value="%{price}" />
Was it helpful?

Solution

Use fmt tag in the body of the struts tag. The body of the tag contains a value in the string form.

<s:textfield id="price" name="products.items[%{#cursor.index}].price"> 
   <fmt:formatNumber value="${price}"/> 
</s:textfield>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top