日期:2014-05-20  浏览次数:20625 次

play framework log 1
1 背景知识自己学习www.playframework.com
2 下载1.2.5,解压。jdk应该已经装过了吧
3 play new helloPlay 新建项目,增加了一个helloPlay 文件夹
4 play run helloPlay 运行
5 http://127.0.0.1:9000看到欢迎界面,环境搭建ok
7 修改helloPlay/conf/application.conf打开db=mem,使用内存数据库
6 在helloPlay/app/controllers下建立Users.java
public class Users extends Controller {
	public static void show(String id) {
		User.findById(id);
		render();
	}
	public static void save(User [color=red]user[/color]) {
		System.out.println(user.name);
		user.save();
		render();
	}
	
}


7 在helloPlay/app/model下建立User.java
@Entity
public class User extends Model {
	public String name;
	public String account;
}


8 在helloPlay/app/views下建立Users/index.html
#{extends 'main.html' /} 

<form action="@{Users.save()}" method="GET">  
    <input type="text" name="[color=red]user[/color].name" />
    <input type="text" name="[color=red]user[/color].account" />    
    <input type="submit" value="Say hello!" />  
</form> 

建立Users/save.html

<html>
    <head>
        
    </head>
    <body>
       save success
    </body>
</html>

9 http://127.0.0.1:9000/Users/index测试参数绑定,ok!注意我标记出来的红色部分必须一致,从而保证参数绑定