【发布时间】:2021-06-02 08:08:32
【问题描述】:
我正在构建 Spring 应用程序并遇到了问题。
我上课了@Entity Balance 它有字段private Long assets;
在 html 表单中,我这样做是为了连接这个字段和输入块:
<input type="text" th:field="${balance.assets}">
Assest 字段以千为单位存储金额(如 123456 = 123 456 000$)
一切正常,但现在我需要打印和读取数百万的输入,但存储数以千计。例如,用户类型 123,456 = 123 456 000$,在 Balance 中应该存储 123456。我真的不想将 assets 字段类型从 Long 更改为 Double。要打印数百万,我可以这样做:
<span th:if="${balance.assets}" th:text="${#numbers.formatDecimal(balance.assets / 1000.0, 0, 'WHITESPACE', 3, 'DEFAULT')}"></span>
我不知道怎么读几百万。
如何在html文件中制作?
谢谢
【问题讨论】:
-
要么在发送时使用 javascript 删除最后一位数字,要么在收到这些数字时在控制器中删除它们。
标签: java html spring spring-mvc thymeleaf