dsk49208 2016-03-28 12:41
浏览 378

Beego框架-API项目-我可以在控制器文件夹中使用文件夹结构吗

I want to group my controllers in some folder structure.

Application works if controllers are directly in 'controllers' folder.

Once I move controller to some controllers sub folder, router is not loading controller at all. (there's not compile errors)

Can anyone help me with that ?

  • 写回答

1条回答 默认 最新

  • douxun4860 2016-03-28 16:32
    关注

    I suspect you don't have the initialization code for your other controller packages.

    For example, if you have a UserController in an admin package, like admin.UserController, you should also have one init() func in that admin package, that looks something like:

    func init() {
        beego.Router("/admin/user", &admin.UserController{})
        // any other controllers register here ...
    }
    

    Also, make sure to import the controller package in your main package, probably as an underscore import if there is nothing directly using it:

    import (
        _ "github.com/foo/bar/controllers/admin"
    )
    
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧