頁(yè)面表單:
<form action='/get' method='Post'>
<tr>
<th>用戶(hù)名</th>
<td>
<input type='text' name='username'>
</td>
</tr>
<tr>
<th>密碼</th>
<td>
<input type='text' name='password'>
</td>
<tr>
<th colspan='2'>
<button id='login'>Login</button>
</th>
</tr>
</tr>
</form
自定義controllers:
//自定義控制器02
type ObjectController struct {
beego.Controller
}
//實(shí)現(xiàn)Post方法
func (this *ObjectController) Post() {
username := this.GetString('username')
password := this.GetString('password')
fmt.Println(username, password)
this.TplName = 'main.tpl'
}
URL參數(shù)也是一樣獲取,Beego框架智能的為我們解析了請(qǐng)求參數(shù),我們只需要通過(guò)key來(lái)獲取即可
聯(lián)系客服