0
我有一些html文本。在里面我想打印从数据库中取得的几个值。这是我创建的html表单。Thymeleaf:如何在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;
}
这些都不是工作 – sndu
你有没有调试代码您能烧开任何您已设置 – Pradeep
对不起,我没有模型属性?我现在有另一个问题。我想获得相关ID的这个持续时间 – sndu