doulu1867 2016-02-16 13:31
浏览 53
已采纳

如何使用“ routes”文件在Revel中读取查询参数?

I am new to Revel and golang. I need help as to how can I access query paramters in Revel and configure it in routes.

Example: localhost:9000/company?name=ABC.

I am sending above get request to fetch the company by name from database. I don't know how can I configure it in the routes file.

My action has

func (c APP) ShowByName(name string){..}

This is how I have set the routes:

GET /company?name:name      APP.ShowByName
  • 写回答

3条回答 默认 最新

  • dongwei3336 2016-03-15 12:44
    关注

    I found solution to this.

    In action I placed the below code :

    c.Params.Query=c.Request.URL.Query()
    var limit int
    c.Params.Bind(&limit,"limit")
    

    and it work for the below URL:

    localhost:9000?limit=21
    

    Here is the complete code for that revel read query parameter

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?