如何为 ok()、status() 等不同方法导入播放框架的结果 class
How play framework's Results class is imported for different methods like ok(), status() etc
我是框架的新手,基本上理解Java很好,但是一旦我看到这段代码,我能得出的关于“结果”的唯一结论class是自动导入的,但是反编译的。class 由 sbt“包”生成的 .jar 文件另有说明。
package controllers;
import play.mvc.Controller;
import play.mvc.Result;
/**
* This controller contains an action to handle HTTP requests
* to the application's home page.
*/
public class HomeController extends Controller {
/**
* An action that renders an HTML page with a welcome message.
* The configuration in the <code>routes</code> file means that
* this method will be called when the application receives a
* <code>GET</code> request with a path of <code>/</code>.
*/
public Result index() {
String str="";
return ok(views.html.index.render());
}
public Result explore() {
return ok(views.html.explore.render());
}
public Result tutorial() {
return ok(views.html.tutorial.render());
}
}
使用版本 2.8.8
您可以在 play.mvc.Controller
中使用 play.mvc.Results
方法,因为它扩展了 Results
class.
控制器 class 是这样声明的:
public abstract class Controller extends Results implements Status, HeaderNames {
...
}
我是框架的新手,基本上理解Java很好,但是一旦我看到这段代码,我能得出的关于“结果”的唯一结论class是自动导入的,但是反编译的。class 由 sbt“包”生成的 .jar 文件另有说明。
package controllers;
import play.mvc.Controller;
import play.mvc.Result;
/**
* This controller contains an action to handle HTTP requests
* to the application's home page.
*/
public class HomeController extends Controller {
/**
* An action that renders an HTML page with a welcome message.
* The configuration in the <code>routes</code> file means that
* this method will be called when the application receives a
* <code>GET</code> request with a path of <code>/</code>.
*/
public Result index() {
String str="";
return ok(views.html.index.render());
}
public Result explore() {
return ok(views.html.explore.render());
}
public Result tutorial() {
return ok(views.html.tutorial.render());
}
}
使用版本 2.8.8
您可以在 play.mvc.Controller
中使用 play.mvc.Results
方法,因为它扩展了 Results
class.
控制器 class 是这样声明的:
public abstract class Controller extends Results implements Status, HeaderNames {
...
}