多页面处理
1、app->views 目录,右键, play2template,生成.scala.html文件*
2、page1.scala.html
@main("Hello page1") {
@defining(play.core.PlayVersion.current) { version =>
<div>I am Page1....</div>
}
}
page2.scala.html page3.scala.html相同
3、conf.route
GET / controllers.HomeController.index()
GET /p1 controllers.HomeController.page1fun()
GET /p2 controllers.HomeController.page2fun()
GET /p3 controllers.HomeController.page3fun()
4、app/controlls/HomeController.scala
def index() = Action { implicit request: Request[AnyContent] =>
Ok(views.html.index())
}
def page1fun() = Action { implicit request: Request[AnyContent] =>
Ok(views.html.page1())
}
def page2fun() = Action { implicit request: Request[AnyContent] =>
Ok(views.html.page2())
}
def page3fun() = Action { implicit request: Request[AnyContent] =>
Ok(views.html.page3())
}
5、main.scala.html 主文件
@(title: String)(content: Html)
<!DOCTYPE html>
<html lang="en">
<head>
<title>@title</title>
</head>
<body>
<ul>
<li><a href="@routes.HomeController.index()">Welcome</a>
<li><a href="@routes.HomeController.page1fun()">页面1</a>
<li><a href="@routes.HomeController.page2fun()">页面2</a>
<li><a href="@routes.HomeController.page3fun()">页面3</a>
</ul>
<div>
@content
</div>
<div>
@title
</div>
</body>
</html>
后续教程,敬请期待。。。