首页 > 其他分享 >beego: panic: 'detail' method doesn't exist in the controller StudentController

beego: panic: 'detail' method doesn't exist in the controller StudentController

时间:2023-06-13 15:03:12浏览次数:39  
标签:src beego StudentController detail github go com astaxie


beego使用报错

panic: 'detail' method doesn't exist in the controller StudentController

goroutine 1 [running]:
github.com/astaxie/beego.(*ControllerRegister).addWithMethodParams(0xc0000d8d10, 0x164d100, 0x7, 0x1736900, 0xc0000c37a0, 0x0, 0x0, 0x0, 0xc000183c08, 0x1, ...)
	/Users/wxx/go/src/github.com/astaxie/beego/router.go:179 +0x969
github.com/astaxie/beego.(*ControllerRegister).Include(0xc0000d8d10, 0xc00015aa60, 0x1, 0x1)
	/Users/wxx/go/src/github.com/astaxie/beego/router.go:286 +0x47b
github.com/astaxie/beego.(*Namespace).Include(...)
	/Users/wxx/go/src/github.com/astaxie/beego/namespace.go:186
github.com/astaxie/beego.NSInclude.func1(0xc0000bbd60)
	/Users/wxx/go/src/github.com/astaxie/beego/namespace.go:302 +0x4b
github.com/astaxie/beego.NewNamespace(0x1653cb8, 0x10, 0xc0000ac660, 0x1, 0x1, 0xc0000bbc60)
	/Users/wxx/go/src/github.com/astaxie/beego/namespace.go:42 +0x87
github.com/astaxie/beego.NSNamespace.func1(0xc0000bb920)
	/Users/wxx/go/src/github.com/astaxie/beego/namespace.go:386 +0x52
github.com/astaxie/beego.NewNamespace(0x1649c8c, 0x3, 0xc000183f48, 0x4, 0x4, 0xc000147140)
	/Users/wxx/go/src/github.com/astaxie/beego/namespace.go:42 +0x87
beego_api/routers.init.2()
	/Users/wxx/go/src/beego_api/routers/router.go:19 +0x3fb

说找不到该方法
但已经写了

// @Title 通过学生卡获取学生详情
// @Description 通过学生卡获取学生详情
// @Param	body		body 	models.User	true		"body for user content"
// @Success 200 {int} models.User.Id
// @Failure 403 body is empty
// @router /detail [get]
func (r *StudentController) detail() {

	card := r.GetString("card")
	organizationId := 22
	res := models.GetInfoByCard(card, organizationId)
	r.Data["json"] = &map[string]interface{}{"data": &res}
	r.ServeJSON()
	return
}

方法名首字母要大写,首字母要大写,首字母要大写,detail改成Detail

func (r *StudentController) Detail()

在go当中,首字母小写包内调用,如果想要包外调用需要首字母大写,go中没有private与public的概念。同一个包内的文件可以看成是一个文件,小写的话就是private,如果在不同的包内,需要首字母大写,相当于java、php中的public属性


标签:src,beego,StudentController,detail,github,go,com,astaxie
From: https://blog.51cto.com/u_16159391/6470218

相关文章

  • beego:interface conversion: interface {} is string, not int
    代码organizationId:=info[0]["organization_id"].(int)报错beego_api:interfaceconversion:interface{}isstring,notintRequestMethod: GETRequestURL: /v1/board2/students/detail2?id=237497RemoteAddr: ::1Stack/usr/local/go/src/runtime/panic.go......
  • https://blog.csdn.net/weixin_58018769/article/details/130380746
     :move="onMove" onMove(e){console.log(e);letmoveName=e.draggedContext.element.name//这个是当前拖拽的控件名//接下来判断该控件要不要拖进指定的容器if(moveName=='禁止拖拽进容器的控件名'&&e.to._prevClass=='要拖进的容器的class名......
  • XXX packages are looking for funding run `npm fund` for details
    原文链接:https://blog.csdn.net/weixin_45895806/article/details/110062752当你刚刚npminstall了一个新的插件之后一般都会报这个提示,并不是报错当你执行npmfund时会出现以下每一个https开头的链接打开都是一个网页,一般均为插件所在的github的地址,又有可能是开发者......
  • svn: E200009: Commit failed (details follow)/both sides of the move must be comm
    今天在提交SVN的时候发生了如下错误,分析了一下原因,试了好几次才找到解决方法,失败原因如下:svn:E200009:Commitfailed(detailsfollow):svn:E200009:Cannotcommit'G:\jiaoyu\src\main\resources\templates\www\xgwy\company\company_content.html'becauseitwasmovedfr......
  • xxxxhttps://blog.csdn.net/holecloud/article/details/80139297
    #include"stdafx.h"#include<opencv2\imgproc\imgproc.hpp>#include<windows.h>#include<opencv2/opencv.hpp>#include<cmath>#include<iostream>//#include"DetectPackage.h"#include<cmath>usin......
  • 使用details和summary元素实现树形展示
    1.先看效果2.默认是关闭的,并且父级关闭后,子级的开关状态会被保留,再次展开时,可恢复;3.需要对details元素增加一个padding-left或margin-left,否则展开后,子级和父级是左对齐的,视觉效果不好;4.一般是details元素套一个summary元素和一个展开后要展示的内容,如果details中没有sum......
  • go1.18版本下 beego/bee安装无法生成exe问题已解决
    我原来的项目是教育学习APP使用gin框架,很多东西都是自己原来实现的。最近开发小程序,需要重新独立后台,又重新找了下go框架研究了下,beego确实是个好框架,至少项目能用到的都考虑进去了。然后发现我本地装了一个下午,beego框架是一直生成了,bee也下载了,就是无法生成exe文件,没有bee.e......
  • 4-2 UserDetails、UserDetailsService和jdbcAuthentication
          ......
  • detail
          ......
  • Java代码虾皮item_search-根据关键词获取商品列表 API 接口(title商品标题、pic_url宝
     Shopee是东南亚最大的电商平台之一。Shopee拥有商品种类,包括电子消费品、家居、美容保健、母婴、服饰及健身器材等。做好shopee店铺需要注意以下几点:1.选择优质的产品2.每日上新产品3.营销策略4.引流策略5.发货的地点Java代码操作示例importjava.io.BufferedReader;impo......