Spring MVC <form:options> selected value
I got relation "Many to one" between my CPVCode adn 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: ...   
}
Everything works well, but I NEED to displays selected value in my form:
开发者_运维技巧<form:select path="orderType"  items="${orderTypes }" itemLabel="title" itemValue="id" ></form:select>
It seems to work almost good: It displays list of all OrderTypes ( by ${orderTypes} which returns array of that objects type), it saves proper values by Hibernate, BUT thereis no way to select current value of orderType after refreshing...
your passing a list to a selectbox, so it iterates over the list. You need to change which bean the selectbox references - a single value oderType from CPVcode.
And also possibly change the selectbox to a different html form element ?
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论