gpt4 book ai didi

java - 以 Spring 形式为单个对象定义 POJO id

转载 作者:行者123 更新时间:2023-12-02 08:10:22 25 4
gpt4 key购买 nike

这是 Controller 发送给我的内容:

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和字段温度。我知道如何发回如图所示的温度,但如何发回我的 id

我想我可以通过${weather.id}从模型中获取它,但是如何将它放在表单中?

最佳答案

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

关于java - 以 Spring 形式为单个对象定义 POJO id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7532011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com