【问题标题】:bindFormRequest() encounter a cannot find symbol error in Play 2.0.3bindFormRequest() 在 Play 2.0.3 中遇到找不到符号错误
【发布时间】:2012-08-21 01:56:59
【问题描述】:

我使用 Play 框架创建了一个表单。但我得到一个error: cannot find symbol 我查看了播放目录中的示例代码,仍然无法弄清楚。顺便问一下,我可以使用 Play 访问 heroku 中的 PostgresSQL 吗? 这是以下代码:

这是 /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));
        }

这是配置/路由:

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 href=@routes.Application.index>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;
    }
  }

【问题讨论】:

    标签: java forms heroku playframework playframework-2.0


    【解决方案1】:

    没有方法 bindFormRequest() 但是bindFromRequest() - 你的代码中有错字。

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

    【讨论】:

    • 谢谢老兄,真是个愚蠢的问题。我在 Google 上花了几个小时。
    • @Ryan 没有愚蠢的问题;)我也花了一段时间才意识到您的错字。无论如何,我建议投资一些好的 IDE - 它可以在几秒钟内而不是几小时内捕获这些烦人的错误。将问题标记为已回答。
    • 谢谢@biesior,我会尽快尝试eclipse
    • 还可以试试 Intellij Idea (Ultimate),它比 Eclipse for Play 更好,恕我直言。
    猜你喜欢
    • 2016-02-10
    • 2012-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多