【问题标题】:Adding UrlMapping constraints to a VERB-mapped url?将 UrlMapping 约束添加到 VERB 映射的 url?
【发布时间】:2011-03-18 19:28:47
【问题描述】:

是否可以为 HTTP 动词匹配的 URL 映射添加约束?

这是我目前的定义:

    "/a/$param1/b" {
        controller = "a"
        action = [GET: 'method1',
                  POST: 'method2'
                 ]
    }

【问题讨论】:

    标签: rest grails groovy url-mapping


    【解决方案1】:

    当然,这似乎有效:

    "/rest/$controller/$id?"(parseRequest:true) {
            action = [GET: "show", POST: "update", PUT:"save", DELETE:"delete"]
            constraints { id(matches:/[0-9]+/) }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-20
      • 2010-09-27
      • 1970-01-01
      • 2013-10-22
      • 1970-01-01
      • 1970-01-01
      • 2012-07-25
      • 1970-01-01
      相关资源
      最近更新 更多