1package main
import (
\t "database/sql"
\t "flag"
\t "fmt"
\t "github.com/astaxie/beego"
)
type User struct {
\t username string
\t password string
}type MainController struct {
\t beego.Controller
}
func (this *MainController) Post() {
\t this.Ctx.WriteString("hello world")
\t result := this.Input()
\t fmt.Println("eedwedwe", this.Input().Get("username"))
\t fmt.Println("input value is", result)
\t fmt.Println("eedwedwe", result.Get("Username"))
\t send := User{username: "vijay", password: "vk18"}
\t this.Data["json"] = &send
\t this.ServeJSON()
}
func main() {
\t beego.Router("/", &MainController{})
\t beego.Run()
}
和請求是如下 捲曲-X POST http://localhost:8080/ -d「{ 「用戶名」: 「管理員」, 「密碼」:」管理員「}」
請求後擊中beego服務器我試圖在請求訪問的用戶名,但其顯示空
和outpit是
2017/02/17 12:56:59 [I] [asm_amd64.s:2086] http server Running on http://:8080
eedwedwe
input value is map[{"username" : "admin", "password":"admin"}:[]]
eedwedwe
謝謝@ user2737515 – gophervk
有同樣的問題,大寫提示工作的感謝! – Abu