2012-08-26 47 views
3

我使用Play框架創建表單。但我得到一個error: cannot find symbol 我查看了播放目錄中的示例代碼,仍然無法弄清楚。順便說一下,我可以使用Play在Heroku中訪問PostgresSQL嗎? 這是以下代碼:bindFormRequest()在Play 2.0.3中遇到無法找到符號錯誤

這是/controllers/Application.java

final static Form<Geo> geoForm = form(Geo.class); 

    public static Result showDBpage(){ 

      //get problem here :-< 
      Form<Geo> filledForm = geoForm.bindFormRequest(); 
      Geo loc = filledForm.get(); 
      return ok(database.render(loc)); 
     } 

一段代碼這是CONF /路線:

POST /database controllers.Application.showDBpage() 

視圖/ database.scala.html

@(loc: Geo) 

@main("") { 

    <p>This is Database pages</p> 

    <p>@loc.longitute and @loc.latitute</p> 

    <a [email protected]>Back to form</a> 
} 

型號/ Geo.java:

package models; 

import java.util.*; 
import javax.validation.*; 
import play.data.validation.Constraints.*; 

public class Geo 
    { 
    @Required 
    public String longitute; 
    @Required 
    public String latitute; 

    public Geo() 
    { 

    } 

    public Geo(String longitude,String latitute) 
    { 
     this.longitute = longitute; 
     this.latitute = latitute; 
     //this.length = length; 
    } 
    } 

回答

7

有沒有方法 bindFormRequest()bindFromRequest() - 你有你的代碼中的拼寫錯誤。

查看API http://www.playframework.org/documentation/api/2.0.2/java/play/data/Form.html

+0

感謝兄弟,這是一個多麼愚蠢的問題。我花了幾個小時在谷歌上。 – Ryan

+0

@Ryan沒有愚蠢的問題;)我花了一段時間才意識到你的錯字。無論如何,我會建議投資一些好的IDE--它可以在幾秒鐘內而不是幾個小時內捕捉到這些煩人的錯誤。將問題標記爲已回答。 – biesior

+0

Thanks @biesior,我會盡快嘗試eclipse – Ryan