play framework log 1

16 篇文章 0 订阅
1 背景知识自己学习[url]www.playframework.com[/url]
2 下载1.2.5,解压。jdk应该已经装过了吧
3 play new helloPlay 新建项目,增加了一个helloPlay 文件夹
4 play run helloPlay 运行
5 [url]http://127.0.0.1:9000[/url]看到欢迎界面,环境搭建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 [url]http://127.0.0.1:9000/Users/index[/url]测试参数绑定,ok!注意我标记出来的红色部分必须一致,从而保证参数绑定
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值