【问题标题】:Defining POJO id in Spring form for single object以 Spring 形式为单个对象定义 POJO id
【发布时间】:2011-09-23 16:20:08
【问题描述】:

这是控制器发送给我的内容:

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 的数据库中得到一个对象。我想通过改变温度来编辑它。所以我必须至少发回id 和字段temperature。我知道如何发回如图所示的温度,但我怎样才能发回我的id

我想我可以从${weather.id} 的模型中得到它,但是我怎样才能将它放在表单中呢?

【问题讨论】:

    标签: java forms spring jsp tags


    【解决方案1】:
    <input type="hidden" name="id" value="${weather.id}">
    

    【讨论】:

      猜你喜欢
      • 2012-04-25
      • 2011-06-19
      • 2016-11-02
      • 2015-01-12
      • 2019-12-17
      • 2018-01-11
      • 1970-01-01
      • 2018-02-10
      • 1970-01-01
      相关资源
      最近更新 更多