我刚刚开始使用spring框架,我发现在将数据插入数据库时出现问题。 输入行程我有一个名字,难度(枚举)。 我的enum Difficolty
public enum Difficolty {
facile("facile"), media("media"), difficile("difficile");
private String name;
private Difficolty(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
我的班级行程
public class Itinerary {
private Long id;
private String name;
private Difficolty difficolty;
..get/set method
form.jsp:
<div>
<label for=id>Difficolty</label>
<div>
<form:select path="difficolty" class="form-control">
<form:option items="0" value="0" label="Seleziona difficoltà" />
<form:options items="${difficolty}" value="${id}" itemLabel="name" />
</form:select>
</div>
</div>
最后,在jdbc实现中我有&#34; insert&#34;方法
//connection, prepareStateent and query...
ps.setString(1, itinerary.getName());
ps.setString(2, itinerary.getDifficolty().toString());
为什么我不能获得选择值?我究竟做错了什么?
提前致谢