0
我不確定如何在Spring MVC表單標籤中定義值屬性。我正在查詢數據庫,我想將數據返回給jsp。我以列表的形式將對象返回給視圖。我想知道如何爲選項列表和輸入框編寫屬性值。在是我的代碼:Spring MVC jsp標籤佔位符標籤值
JSP
<form:form id="citizenRegistration" name ="citizenRegistration" method="POST" commandName="citizens" action="citizen_registration.htm">
<li>
<label>Select Gender</label><form:select path="genderId" id="genderId" title="Select Your Gender"><form:options items = "${gender.genderList}" selected=???? itemValue="genderId" itemLabel="genderDesc" />
</form:select><form:errors path="genderId" class="errors"/>
</li>
<li><form:label for="weight" path="weight">Enter Weight <i>(lbs)</i></form:label>
<form:input path="weight" id="weight" title="Enter Weight" value= ???/><form:errors path="weight" class="errors"/>
</li>
JavaDao
該函數返回: ................... .....
List<Citizens> listOfCitizens = getJdbcTemplate().query(sql, new CitizensMapper());
return listOfCitizens;
控制器
if (user_request.equals("Query")){
logger.debug("about to preform query");
citizenManager.getListOfCitizens(citizen);
if(citizenManager.getListOfCitizens(citizen).isEmpty()){
model.addAttribute("icon","ui-icon ui-icon-circle-close");
model.addAttribute("results","Notice: Query Caused No Records To Be Retrived!");
}
//how do i return the List<Citizens> listOfCitizens
//or what should be done to send the user the data from the database
return new ModelAndView("citizen_registration");
}
爲什麼我的回報listOfCitizens不是值返回到屬性。該函數的定義如下public List getListOfCitizens(Citizens citizen){......從數據庫獲取數據..... return listOfCitizens;} –
devdar
2013-03-04 20:07:38
我做了一個從數據庫中檢查並且列表不是NULL的數據,一條記錄 – devdar 2013-03-04 20:08:22
由您的控制器方法爲JSP提供模型。你的是否這樣做? – GriffeyDog 2013-03-04 20:13:49