-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
无法解析数组参数 #16
Comments
你这用法不对吧, |
写法没问题哦..http的数组是这样传的 PHP和python都能正确接收 |
代码举证?。。。 另外你试了我说的方法了吗。。? |
可以得到form.Args为2 在php中 $_GET['args']的值为 array(1, 2)
在php中只能得到$_GET['args']为 2 原因同上 |
我问的是 Go 的代码举证。。 |
type ConsoleForm struct {
Args []string form:"args[]";
} 我也遇到这个问题,我按如上方式绑定, Args依然为空数组[] |
不要使用PHP的方式 试试 command=run&args=1&args=2 |
https://github.com/gin-gonic/gin/issues/129 如果像下面这样的参数
macaron应该怎样接收呢 |
我测了完全没问题啊,用的 gin-gonic/gin#129 (comment) 里 form 的例子: package main
import (
"fmt"
"github.com/go-macaron/binding"
"gopkg.in/macaron.v1"
)
type ConsoleForm struct {
Args []string `form:"colors[]"`
}
func main() {
m := macaron.Classic()
m.Use(macaron.Renderer())
m.Post("/", binding.Bind(ConsoleForm{}), func(form ConsoleForm) {
fmt.Println(form)
})
m.Run()
}
|
type ConsoleForm struct {
Operation string `form:"operation"`
Command string `form:"command"`
Args []string `form:"args[]"`
} 可以使用这样来获取 |
发送参数operation=test&command=run&args[]=1&args[]=2
args无法映射到struct中
The text was updated successfully, but these errors were encountered: