1

我做了以下事情

=> controllers.Application

object Application extends Controller {

  val studentForm = Form(

    mapping(

      "FirstName" -> text,

      "MiddleName" -> text,

      "LastName" -> text,

      "RollNumber" -> number,

      "TemporaryAddress" -> text,

      "PermanentAddress" -> text,

      "Faculty" -> text,

      "Section" -> text,

      "ContactNumber" -> number,

      "Email" -> text

    )(StudentInfo.apply)(StudentInfo.unapply)

  )

  def saveForm = Action {/* implicit request =>

    studentForm.bindFromRequest.fold(

      errors => (BadRequest("Error")),

      res => */ Ok(views.html.forms(studentForm))


    }


   }

=> models

package models


import play.api.libs.json.Json


/**

  * Created by milan on 9/26/16.

  */

case class StudentInfo (

  FirstName: String,

  MiddleName:String,

  LastName:String,

  RollNumber:Int,

  TemporaryAddress:String,

  PermantAddress:String,

  Faculty:String,

  Section:String,

  ContactNumber:Int,

  Email:String)

  {


   }
object StudentInfo {

  implicit val info = Json.format[StudentInfo]


}

=> routes

GET  /forms                               controllers.Application.saveForm

这给出了表单。现在我需要在不使用视图的情况下连接数据库,即

与 json.And 我需要使用 Mongodb 和 reactiveMongo.Can 任何人都可以帮助我

做这个?

4

0 回答 0