我无法修复的 Play Framework 路由错误
Play Framework routing error that I can't fix
我正在使用 Play Framework 构建我的第一个控制器。我收到错误消息:
Compilation error value getAll is not a member of controllers.api.protocol.Period
我的 routes.conf 文件如下所示:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
GET /api/protocol/period controllers.api.protocol.Period.getAll()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
和 "controllers/api/protocol/Period.java" 看起来像:
package controllers.api.protocol;
import com.avaje.ebean.Model;
import play.mvc.Controller;
import java.util.List;
import play.mvc.*;
import static play.libs.Json.toJson;
public class Period extends Controller {
public static Result getAll() {
List<model.Protocol.Period> periods = new Model.Finder<Integer.class>(model.Protocol.Period.class).all();
return ok(toJson(periods));
}
}
我迷路了
太好了,欢迎。 :)
从 public static Result getAll()
中删除 static
,您就排序了。
我正在使用 Play Framework 构建我的第一个控制器。我收到错误消息:
Compilation error value getAll is not a member of controllers.api.protocol.Period
我的 routes.conf 文件如下所示:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
GET /api/protocol/period controllers.api.protocol.Period.getAll()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
和 "controllers/api/protocol/Period.java" 看起来像:
package controllers.api.protocol;
import com.avaje.ebean.Model;
import play.mvc.Controller;
import java.util.List;
import play.mvc.*;
import static play.libs.Json.toJson;
public class Period extends Controller {
public static Result getAll() {
List<model.Protocol.Period> periods = new Model.Finder<Integer.class>(model.Protocol.Period.class).all();
return ok(toJson(periods));
}
}
我迷路了
太好了,欢迎。 :)
从 public static Result getAll()
中删除 static
,您就排序了。