【发布时间】:2018-02-24 05:04:08
【问题描述】:
我有一些 html 文本。在其中我想打印从数据库中获取的几个值。这是我创建的 html 表单。
<form id="deal-form"
th:object="${deal}" method="post">
<div class="border-t p-y-10">
<i class="fa fa-calendar" aria-hidden="true"></i> Duration<br/>
Ads between <span th:value = "${hotDealDetail}" th:utext="${duration}">time</span>
</div>
</form>
持续时间值取自数据库并使用 Thymeleaf 包含在 html 文本中。这是控制器方法。
@ModelAttribute("hotDealDetail")
public String hotDealDetail( ModelMap model) {
model.addAttribute("deal", new Deal());
return "hot-deal-detail";
}
我没有发现任何错误。但是不会打印从数据库中获取的值。我错过了什么?
编辑: 交易类
@Entity
@Table(name = "deal")
public class Deal {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
//in seconds
private double duration;
@OneToMany(mappedBy = "deal")
private List<DealEntry> dealEntries;
@Transient
private DealEntry newDealEntry;
public Deal() {
value = new BigDecimal(00.00);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
public double getDuration() {
return duration;
}
public void setDuration(double duration) {
this.duration = duration;
}
【问题讨论】:
标签: java html spring-mvc thymeleaf