Spring MVCselected value
我得到了我的CPVCode和OrderType之间的多对一关系:Spring MVCselected value,select,spring-mvc,Select,Spring Mvc,我得到了我的CPVCode和OrderType之间的多对一关系: public class CPVCode { @Id @GeneratedValue private int id; private String cpv_code; private String description; @ManyToOne @JoinColumn(name="id_parent") private OrderType orderType; //
public class CPVCode {
@Id
@GeneratedValue
private int id;
private String cpv_code;
private String description;
@ManyToOne
@JoinColumn(name="id_parent")
private OrderType orderType;
//getters na setters: ...
}
一切正常,但我需要在表格中显示选定的值:
<form:select path="orderType" items="${orderTypes }" itemLabel="title" itemValue="id" ></form:select>
它似乎工作得很好:它通过${OrderTypes}显示所有OrderTypes的列表,返回该对象类型的数组,它通过Hibernate保存适当的值,但在刷新后无法选择orderType的当前值…将列表传递给selectbox,因此它会在列表上迭代。您需要更改selectbox引用的bean-CPVcode中的单个值oderType
还可能将selectbox更改为不同的html表单元素?您需要更改selectbox引用的bean-来自CPVcode的单值oderType。-怎么做?