我有两个名为的项目:
我在" old"用radiobutton和一些文本字段来输入年龄,体重,...... 然后我做了一个新项目(激活新的新项目)并进一步开发了表格。控制器预先填写表格,预先选择单选按钮等。 现在我想更新" old"并复制了" new"进入" old"。 在所有控制器类中,在所有模型类中,在所有视图中,类是完全相同的代码!我甚至手动多次检查文件大小,但是" old"表格没有预先填写!无论我做什么,都没有任何反应。我不知道为什么会发生这种情况以及做什么。
我的代码:
Application.java:
package controllers;
import models.User;
import play.data.Form;
import play.mvc.Controller;
import play.mvc.Result;
public class Application extends Controller {
static Form<User> userForm = Form.form(User.class);
public static Result index() {
User user = new User();
Form<User> preFilledForm = userForm.fill(user);
return ok(views.html.index.render(preFilledForm));
}
}
User.java:
package models;
public class User {
public Integer gewicht;
public Integer groesse;
public Integer alter;
public Float grundUmsatz;
public String geschlecht = "Mann";
public User(){
gewicht = 0;
groesse = 0;
alter = 0;
geschlecht = "Mann";
}
}
index.scala.html:
@(userForm : Form[User])
@import helper._
@import helper.twitterBootstrap._
@main("App - index") {
@helper.form(action = routes.Application.submit(), 'id -> "userForm"){
<fieldset>
@helper.inputRadioGroup(
userForm("Geschlecht"),
options = options("Mann"->"Mann","Frau"->"Frau"),
'_label -> "Gender",
'_error -> userForm("Geschlecht").error.map(_.withMessage("select gender"))
)
</fieldset>
@helper.inputText(userForm("Gewicht"))
@helper.inputText(userForm("Groesse"))
@helper.inputText(userForm("Alter"))
<input type="submit" class="btn primary" value="Send">
}
}
main.scala.html:
@(title: String)(content: Html)
<!DOCTYPE html>
<html>
<head>
<title>@title</title>
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
<script src="@routes.Assets.at("javascripts/hello.js")" type="text/javascript"></script>
</head>
<body>
@content
</body>
</html>
路由文件:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
POST /auswertung/ controllers.Application.submit()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)