Scala &引用;“对象形式中的方法映射”;错误
我正在尝试使用带有Scala的Play框架构建一个基本应用程序,我尝试从提供的表单示例中复制,但现在遇到了问题 在浏览器中刷新时,我收到以下错误 我已经查看了样本上的所有文件,但似乎无法确定问题在哪里,我对此非常陌生,原因可能很简单,但我担心这次谷歌让我失望了 如果有人能为我指出正确的方向,我将非常感激 谢谢 来自主文件的代码 /控制员/意见书Scala &引用;“对象形式中的方法映射”;错误,scala,playframework,Scala,Playframework,我正在尝试使用带有Scala的Play框架构建一个基本应用程序,我尝试从提供的表单示例中复制,但现在遇到了问题 在浏览器中刷新时,我收到以下错误 我已经查看了样本上的所有文件,但似乎无法确定问题在哪里,我对此非常陌生,原因可能很简单,但我担心这次谷歌让我失望了 如果有人能为我指出正确的方向,我将非常感激 谢谢 来自主文件的代码 /控制员/意见书 object Submission extends Controller { val contactForm:Form[Contact] =
object Submission extends Controller {
val contactForm:Form[Contact] = Form(
mapping(
"title" -> text,
"firstname" -> text,
"lastname" -> text,
"gender" -> text,
"dob" -> text,
"mobile" -> text,
"landline" -> text,
"email" -> text,
"housenumber1" -> text,
"housename1" -> text,
"address11" -> text,
"address12" -> text,
"address13" -> text,
"address14" -> text,
"address15" -> text,
"postcode1" -> text,
"country1" -> text )
)
def submit = TODO
/型号/联系人
package models
case class Contact(
title: String,
firstname: String,
lastname: String,
gender: String,
dob: String,
mobile: String,
landline: String,
email: String,
housenumber1: String,
housename1: String,
address11: String,
address12: String,
address13: String,
address14: String,
address15: String,
postcode1: String,
country1: String
)
/视图/application.scala.html
@(contactForm: Form[Contact])
@import helper._
@import helper.twitterBootstrap._
@title = {Overseas Application}
@main(title) {
@helper.form(action = routes.Submission.submit) {
<fieldset>
<legend>Personal Information</legend>
@inputText(contactForm("title"),'_label -> "Title")
@inputText(contactForm("firstname"),'_label -> "First Name")
@inputText(contactForm("lastname"),'_label -> "Last Name")
@inputText(contactForm("gender"),'_label -> "Gender")
@inputText(contactForm("dob"),'_label -> "Date of Birth")
@inputText(contactForm("mobile"),'_label -> "Mobile")
@inputText(contactForm("landline"),'_label -> "Landline")
@inputText(contactForm("email"),'_label -> "Email")
</fieldset>
<fieldset>
<legend>Address 1</legend>
@inputText(contactForm("housenumber1"),'_label -> "House Number (1)")
@inputText(contactForm("housename1"),'_label -> "House Name(1)")
@inputText(contactForm("address11"),'_label -> "Address Line 1 (1)")
@inputText(contactForm("address12"),'_label -> "Address Line 2 (1)")
@inputText(contactForm("address13"),'_label -> "Address Line 3 (1)")
@inputText(contactForm("address14"),'_label -> "Address Line 4 (1)")
@inputText(contactForm("address15"),'_label -> "Address Line 5 (1)")
@inputText(contactForm("postcode1"),'_label -> "Postcode (1)")
@inputText(contactForm("country1"),'_label -> "Country (1)")
</fieldset>
<div class="actions">
<input type="submit" class="btn primary" value="Submit">
</div>
}
}
@(contactForm:Form[Contact])
@导入助手_
@导入helper.twitterBootstrap_
@title={海外申请}
@主要(标题){
@helper.form(action=routes.Submission.submit){
个人信息
@输入文本(联系方式(“标题”),“U标签->标题”)
@输入文本(联系方式(“名字”),“标签->名字”)
@输入文本(联系方式(“姓氏”),“标签->姓氏”)
@输入文本(联系方式(“性别”),“U标签->性别”)
@输入文本(联系方式(“dob”),“标签->出生日期”)
@输入文本(联系方式(“手机”),“U标签->手机”)
@输入文本(联系方式(“固定电话”),“U标签->固定电话”)
@输入文本(联系方式(“电子邮件”),“U标签->电子邮件”)
地址1
@输入文本(联系方式(“门牌号1”),“U标签->门牌号(1)”)
@输入文本(联系方式(“房屋名称1”),“U标签->房屋名称(1)”)
@输入文本(联系方式(“地址11”),“U标签->地址行1(1)”)
@输入文本(联系方式(“地址12”),“U标签->地址行2(1)”)
@输入文本(联系方式(“地址13”),“U标签->地址行3(1)”)
@输入文本(联系方式(“地址14”),“U标签->地址行4(1)”)
@输入文本(联系方式(“地址15”),“U标签->地址行5(1)”)
@输入文本(联系方式(“邮政编码1”),“标签->邮政编码(1)”)
@输入文本(联系方式(“国家1”),“U标签->国家(1)”)
}
}
请参见
映射方法只允许您定义自定义函数。当你
要构造和解构一个case类,可以使用它的
默认应用和取消应用函数,因为它们正是这样做的
映射的签名到底是什么,您可以在$上找到
val userForm:Form[Contact] = Form(
mapping(
"title" -> text,
"firstname" -> text,
"lastname" -> text,
"gender" -> text,
"dob" -> text,
"mobile" -> text,
"landline" -> text,
"email" -> text,
"housenumber1" -> text,
"housename1" -> text,
"address11" -> text,
"address12" -> text,
"address13" -> text,
"address14" -> text,
"address15" -> text,
"postcode1" -> text,
"country1" -> text
)(Contact.apply)(Contact.unapply)
)