【问题标题】:Play framework form parameter播放框架表单参数
【发布时间】:2014-11-21 22:23:08
【问题描述】:

我首先想说的是,我对玩框架是全新的,我从 'whereIsMyDipp' 的 youtube 教程中获得了这段代码,但它不起作用,我查看了文档和其他教程并且可以'想不出这个。我正在使用的播放版本是 2.3.6 我正在尝试使用 @helper 的东西创建一个基本的联系人表单,但我收到了这个错误: 截图链接:http://imgur.com/keKda1G

not found: value contactForm   

这是我的看法:

@import helper._
@import helper.twitterBootstrap._
@(contactForm: Form[Contact])
@main("wat"){
@helper.form(action = routes.Application.contactSubmit()) {
@helper.inputText(contactForm("fName"))
@helper.inputText(contactForm("lName"))
@helper.inputText(contactForm("phone"))
@helper.inputText(contactForm("email"))
@helper.inputText(contactForm("subject"))
@helper.inputText(contactForm("message"))

}
    }

下面是相关的Action方法和模型:

public class Contact {
String fName;
String lName;
String phone;
String email;
String subject;
String message;}

 final static Form<Contact> contactForm = form(Contact.class);

 public static Result ContactUs() {
    return ok(ContactUs.render(contactForm));
}

 public static Result contactSubmit() {
 Form<Contact> filledForm = form(Contact.class).bindFromRequest();
 Contact created = filledForm.get();
 return ok(submit.render(created));}

【问题讨论】:

    标签: java scala playframework playframework-2.0


    【解决方案1】:

    参数必须在模板文件的第一行声明,所以@(contactForm: Form[Contact])应该排在最前面..

    【讨论】:

    • 是的,我以前也是这样,也遇到了同样的错误,把它移到第三行是一种绝望的行为。
    猜你喜欢
    • 2012-04-20
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    • 1970-01-01
    • 2015-05-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多