2011-09-23 35 views
0

定義POJO ID這是控制器發送給我:春季形式單一對象

model.addAttribute("weather", weatherService.getWeatherByCity(id)); 

這是我的JSP:

<form:form commandName="newWeather" method="post" action="edit"> 
    <c:forEach items="${cities}" var="city"> 
     <form:input path="temperature"></form:input> 
     <input type="submit" value="Submit"> 
    </c:forEach> 
</form:form> 

問題:

我從一個物體數據庫名爲weather。我想通過改變溫度來編輯它。所以我必須至少發回idtemperature。我知道如何發送回溫度,但我怎樣才能發回我的id

我想我可以從模型得到${weather.id},但我怎樣才能把它放在窗體中?

回答

2
<input type="hidden" name="id" value="${weather.id}">