Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring MVCselected value_Select_Spring Mvc - Fatal编程技术网

Spring MVCselected value

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; //

我得到了我的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;
//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。-怎么做?