2012-07-18 64 views
3

我下载并安装了play framework 2.0.2,然后创建了一个项目。我越过了这个项目并在日食中打开它。渲染函数在播放框架2.0.2中不存在?

我有一个叫做Application的类,它扩展了Controller类。在网络上的大多数例子中,我看到如下的控制器。

public class Application extends Controller { 
    public static void index() { 
     render(arg0,arg1,...); 
    } 

    public static void tasks() { 
     render(arg0,arg1,...); 
    } 

    public static void newTask() { 
     render(arg0,arg1,...); 
    } 

    public static void deleteTask(Long id) { 
     render(arg0,arg1,...); 
    } 
} 

但是在我的默认应用程序中,我只能执行以下操作。我不知道如何做前一个。

public class Application extends Controller { 
    public static Result index() { 
     return ok("Hello World!"); 
    } 

    public static Result tasks() { 
     return ok(indexabc.render("hello world")); 
    } 

    public static Result newTask() { 
     return TODO; 
    } 

    public static Result deleteTask(Long id) { 
     return TODO; 
    } 
} 

在我的代码中,当我尝试用“void”替换“Result”返回类型时,没有任何问题。但是,当我想用​​某些参数调用“render()”方法时,该方法不存在。我无法找到如何调用渲染函数的方法。

回答

3

你看到周围的网络的例子是播放1.x中,你已经在你的控制器拿到的版本是2.x版本播放

播放1使用render(),播放2返回一个Result对象,该对象通过调用ok()方法或许多其他方法创建。

此时有2个选项。下载Play 1.2.5(当前稳定版本)并使用您找到的示例,或使用Play 2.x文档并搜索Play 2.x示例。

+0

感谢您的回复 – 2012-07-18 14:59:00