对我来说,更改ploeg的价值双关语是不可能的。我做了一个按钮,该按钮触发了将改变点但没有任何反应的功能。这是我的按钮:
@form(routes.Application.geefPunten(ploeg.id)) {
<input type="submit" value="Gewonnen">
}
这是我在Aaplication.java中调用的函数:
public static Result geefPunten(Long id) {
Ploeg.geefPunt(id);
return redirect(routes.Application.ploegen());
}
然后这是我的Ploeg.java中的函数,应该更改punten的值:
public static void geefPunt(Long id) {
Ploeg ploegje = find.byId(id);
ploegje.punten = ploegje.punten + 3;
}
这是我的路由文件,我认为它出错了:
# Home page
GET / controllers.Application.index()
# Ploegen
GET /ploegen controllers.Application.ploegen()
# POST /ploeg/:id controllers.Ploeg.zoekPloeg(id: Long)
POST /ploegen/:id/punten controllers.Application.geefPunten(id: Long)
POST /ploegen/:id/delete controllers.Application.deletePloeg(id: Long)
POST /ploegen/maak controllers.Application.maakPloeg()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
我个人认为路线出了问题,但我找不到问题。已经搜寻了几天。
最佳答案
更改后需要保存:
ploegje.save();