---
title: "play framework log 1"
author: "fourfire"
date: "2013-07-23T21:47:07Z"
tags: []
categories: ["开源软件"]
slug: "play-framework-log-1"
draft: false
lastmod: "2013-07-23T21:48:33Z"
id: 1912386
url: "https://fourfire.iteye.com/blog/1912386"
---

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

```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

```java

@Entity
public class User extends Model {
	public String name;
	public String account;
}

```


8 在helloPlay/app/views下建立Users/index.html

```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

<html>
    <head>
        
    </head>
    <body>
       save success
    </body>
</html>

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