Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法分析来自beego的已发布表单数据_Go_Beego_Go Html Template - Fatal编程技术网

无法分析来自beego的已发布表单数据

无法分析来自beego的已发布表单数据,go,beego,go-html-template,Go,Beego,Go Html Template,我是新手,正在体验比戈 我正在尝试从以下位置获取已发布的表单数据: <form action="/hello" method="post"> {{.xsrfdata}} Title:<input name="title" type="text" /><br> Body:<input name="body" type="text" /><br> <input type="submit" v

我是新手,正在体验比戈

我正在尝试从以下位置获取已发布的表单数据:

 <form  action="/hello" method="post">
    {{.xsrfdata}}
    Title:<input name="title" type="text" /><br>
    Body:<input name="body" type="text" /><br>    
    <input type="submit" value="submit" />
    </form>
但我得到的不是输入到字段中的字符串值:

Your note title is %!s(*string=0xc82027a368)
Your note body is %!s(*string=0xc82027a378)

我跟着请求处理,但不知道为什么不能发布字符串

根据文档,定义接收器结构的方法应该是使用结构类型,而不是指向该结构的指针:

func (this *MainController) Post() {
    u := User{}
    if err := this.ParseForm(&u); err != nil {
        //handle error
    }
}
然后,在控制器中,如果您

func (this *HelloController) Post() {
    n := Note{}
    ...
 }

关于go中指针的更多信息:

从文档中,定义接收器结构的方法应该是使用结构类型,而不是指向该结构的指针:

func (this *MainController) Post() {
    u := User{}
    if err := this.ParseForm(&u); err != nil {
        //handle error
    }
}
然后,在控制器中,如果您

func (this *HelloController) Post() {
    n := Note{}
    ...
 }

关于go中指针的更多信息:

您正在获取指针地址,如果您将log.Printf(“您的注释标题是%s,&n.title”)更改为此->log.Printf(“您的注释标题是%s”,n.title”),那么我会得到类似
的内容,您的注释标题是0xc820267d18
但是,请检查文档以定义结构的方式(在你的例子中,Note)是作为一个结构类型,而不是作为指向该结构的指针(&),那么在你的代码中你应该是n:=Note{}你是对的。请回答,我会接受。谢谢!你得到了指针地址,如果你更改log.Printf(你的注释标题是%s,&n.title)这个->log.Printf(“你的注释标题是%s”,n.title)呢然后我得到了类似于
的东西,你的笔记标题是0xc820267d18
,但是,检查文档的方式来定义结构(在你的例子中是笔记)是作为一个结构类型,而不是作为指向该结构的指针(&),那么在你的代码中你应该是n:=注意{}你是对的。请回答,我会接受。谢谢!