我使用 Spring MVC 作为我的 Spring 应用程序的前端。我有一个放入模型的对象,其中包含我的报告的所有值。它看起来像这样:
public class AggregateResultBean {
private String regionName;
private String countryName;
private String indicatorId;
@NumberFormat(pattern="#,###,###.00")
private HashMap<String, BigDecimal> indicatorValues;
.
.
.
}
在我的 jsp 中,我遍历了一个月份列表,例如 Jan97、Feb97 等,它们是上面 indicatorValues 哈希图的键,我得到了特定月份的 indicatorValue。
我想格式化该值,但上面的代码并没有解决问题。
第二个更复杂的部分是我希望 numberFormatter 成为 Percent Formatter,例如,indicatorId = 5 或其他东西。我将如何使用注释(甚至没有注释)来做到这一点?