默認

2015-01-14 97 views
0
Design a form(<spring:form></spring:form>) in JSP using Spring MVC architecture 

從控制器Enum.values綁定模型屬性默認

看我使用綁定的組合和默認值選擇列表什麼碼值。

m.addAttribute("questTypes", Enum.values()); 

    m.addAttribute("defsel", Enum.Value1.getName()); 

然後JSP頁面上寫這樣的代碼

<form:select path="otquestion.otQuestionId" class="combobox required" style="float:left;" id="selectQuestid"> 
    <form:option label="Select Question Type..." value=""></form:option> 
    <form:options items="${questTypes}" selected="${defsel}" itemLabel="name" itemValue="value"></form:options> 
    </form:select> 

最後名單的來源,但組合的默認選擇不工作。請幫助

+0

檢查http://forum.spring.io/forum/spring-projects/web/73245-form-select-tag-chose-one-option-as-selected – kranthi117

+0

我已經在forum.spring上通過了。 io/forum/spring-projects/web/73245-form-select-tag-chosen-one-option -as-selected,但沒有得到任何答案。 –

回答

0

我通過以下方式獲得答案,路徑=「otquestion.otQuestionId」的值。 在otquestion對象中,otQuestionId成員變量設置值並通過模型對象返回該對象。