我有我的网站,它可以写一些东西。然后我的服务可以获取这些数据并保存在我的数据库中,但它对我不起作用。我尝试了一些步骤,似乎可以将字符串传输到 dab(),但它无法在我的数据库中保存任何内容。错误日志:2016/05/14 08:02:08 http: panic serving 14.146.246.141:64540: sql: converting argument #0's type: unsupported type []string, a slicegoroutine 5 [running]:net/http.(*conn).serve.func1(0xc8200b4f20, 0x7f8b9f86c6c8, 0xc820024038) /usr/lib/golang/src/net/http/server.go:1287 +0xb5main.checkErr(0x7f8b9f867028, 0xc82000b4a0) /home/Mario/a.go:50 +0x4bmain.dab(0xc82000b360, 0x1, 0x1, 0xc82000b370, 0x1, 0x1) /home/Mario/a.go:41 +0x306main.handle(0x7f8b9f86c848, 0xc8200b5550, 0xc8200de2a0) /home/Mario/a.go:28 +0x4a7net/http.HandlerFunc.ServeHTTP(0x876a90, 0x7f8b9f86c848, 0xc8200b5550, 0xc8200de2a0) /usr/lib/golang/src/net/http/server.go:1422 +0x3anet/http.(*ServeMux).ServeHTTP(0xc820012930, 0x7f8b9f86c848, 0xc8200b5550, 0xc8200de2a0) /usr/lib/golang/src/net/http/server.go:1699 +0x17dnet/http.serverHandler.ServeHTTP(0xc820016120, 0x7f8b9f86c848, 0xc8200b5550, 0xc8200de2a0) /usr/lib/golang/src/net/http/server.go:1862 +0x19enet/http.(*conn).serve(0xc8200b4f20) /usr/lib/golang/src/net/http/server.go:1361 +0xbeecreated by net/http.(*Server).Serve /usr/lib/golang/src/net/http/server.go:1910 +0x3f6代码片段:package mainimport ( "net/http" "log" "fmt" "html/template" _ "github.com/go-sql-driver/mysql" "database/sql")func Mai(w http.ResponseWriter, r *http.Request){ t, _ := template.ParseFiles("a.js") t.Execute(w, nil)}func FormServer(w http.ResponseWriter, r *http.Request){ t, _ := template.ParseFiles("an.html") t.Execute(w, nil)}func handle(w http.ResponseWriter, r *http.Request){ r.ParseForm() fmt.Println("title:", r.Form["title"]) fmt.Println("main:", r.Form["main"]) a := r.Form["title"] b := r.Form["main"] dab(a , b) // t, _ := template.ParseFiles("finish.html") // t.Execute(w, nil)}我该如何解决?
- 1 回答
- 0 关注
- 150 浏览
添加回答
举报
0/150
提交
取消