I am using Struts2 to format a string to number with trim trailing zeros.
messages.properties :
format.number={0,number,#}
jsp code :
<s:text name="format.number">
<s:param name="value" value="%{key.policyNumber}" />
</s:text>
key.policyNumber is a String, I am getting the error as “Error 500: java.lang.IllegalArgumentException: Cannot format given Object as a Number“
UPDATE: I tried the same code giving a Integer then it works. like
<s:text name="format.number">
<s:param name="value" value="%{key.orderNum}" />
</s:text>
action class
Map<PolicyObj, CustInfo> mapObj = getDBPolicyDetails();
In DB class
PolicyObj.setPolicyNumber("0000111111");
Small change in JSP code. I kind of tricked by converting the string to number.
Here is the code.
multiplying by 1 is one change I did and it worked.