【发布时间】:2015-06-16 07:40:15
【问题描述】:
我有 2 个项目的名称:
- 旧
- 新
我用单选按钮和一些文本字段在“旧”中制作了一个表单,用于输入年龄、体重…… 然后我做了一个新项目(activator new new)并进一步开发了表格。控制器预先填写表格,预先选择单选按钮等。 现在我想更新“旧”并将代码从“新”复制到“旧”中。 在所有控制器类中,在所有模型类中,在所有视图类中都是完全相同的代码!我什至多次手动检查文件大小,但在“旧”表格中没有预先填写!不管我做什么,什么都不会发生。我不知道为什么会发生这种情况以及该怎么做。
我的代码:
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)
【问题讨论】:
-
忘了说:我在 Scala IDE 中使用 Play 2.3.8。我还在几个浏览器中测试了网页,清理了 webbrowsers 的缓存,在 eclipse 中制作了“清理项目”,尝试了“activator eclipse”,......到目前为止没有任何帮助。
-
您是否尝试过先执行
activator clean,然后执行activator run,然后在浏览器中打开? -
嗯……那行得通。似乎您应该不时停顿一下并停止坐在计算机前。似乎没有想到“活化剂清洁”。谢谢!
标签: java html forms scala playframework