【发布时间】:2014-07-19 20:01:49
【问题描述】:
我是 Play Framework 的新手,我正在尝试开发示例 java 应用程序
我创建了新的 html 页面 test.html
在控制器中,如果我们简单地以字符串的形式返回结果,即返回 ok("hello world"),它就可以工作,但它只是格式化所有样式/文本并在 UI 上显示“hello world”。
public static Result test() {
return ok("hello world");
}
// 工作正常
但是当我尝试这个时它会出错
public static Result test(){
return ok(test.render());
}
//给出错误
它给出以下错误
[错误] /opt/ahsen/play-2.2.3/testapp/app/controllers/Application.java:15:views.html 中的渲染(java.lang.String,play.api.templates.Html)。测试不能应用于 ()
[错误] 返回 ok(test.render());
[error] (compile:compile) javac 返回非零退出代码
这是我的 test.html 文件
@(title: String)(content: Html)
<!DOCTYPE html>
<html>
<head>
<title>@title</title>
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
<script src="@routes.Assets.at("javascripts/jquery-1.9.0.min.js")" type="text/javascript">
</script>
</head>
<body>
@content
</body>
</html>
请帮忙
【问题讨论】:
标签: java eclipse playframework-2.0