1.在views下创建名为Home的包,在包中新建Play 2 Template名为welcome
2.引包:
import views.html.index;
import views.html.Home.*;
3.在welcome中:
@(name:String,lastname:String)
<html>
<head>
<title>my welcome page</title>
</head>
<body>
<p>Welcome @name @lastname To our website</p>
</body>
</html>
4.在HomeController中定义方法:
public Result welcome(String name, String lastname) {
return ok(welcome.render(name, lastname));
}
效果:在网页上输入localhost:9000/welcome/:xxx/xx得到响应(xxx为任意输入名称)都可以显示