Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.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
Grails是否缺少对http选项请求的支持?_Http_Grails_Url Mapping_Http Options Method - Fatal编程技术网

Grails是否缺少对http选项请求的支持?

Grails是否缺少对http选项请求的支持?,http,grails,url-mapping,http-options-method,Http,Grails,Url Mapping,Http Options Method,当我在下面创建Grails2.2.4应用程序时,我看到了对POST/options/somewhere的响应,但没有看到对options/options/somewhere的响应 是否有某种方法可以对选项请求调用控制器操作 POST起作用而选项不起作用的应用程序: $ grails create-app options $ grails create-controller api UrlMappings.groovy: class UrlMappings { static mapping

当我在下面创建Grails2.2.4应用程序时,我看到了对
POST/options/somewhere
的响应,但没有看到对
options/options/somewhere
的响应

是否有某种方法可以对选项请求调用控制器操作


POST
起作用而
选项
不起作用的应用程序:

$ grails create-app options
$ grails create-controller api
UrlMappings.groovy

class UrlMappings {
  static mappings = {
    "/somewhere" (controller: "api", parseRequest: true) {
      action = [OPTIONS: "getOptions", POST: "saveStuff"]
    } 
  } 
}
package options

class ApiController {
    def getOptions() {
      render("Your options await.")
    }
    def saveStuff() {
      render("Stuff saved.")
    }
}
ApiController.groovy

class UrlMappings {
  static mappings = {
    "/somewhere" (controller: "api", parseRequest: true) {
      action = [OPTIONS: "getOptions", POST: "saveStuff"]
    } 
  } 
}
package options

class ApiController {
    def getOptions() {
      render("Your options await.")
    }
    def saveStuff() {
      render("Stuff saved.")
    }
}
请尝试以下代码:

 "/somewhere" (controller: "api", parseRequest: true) { //controller name begins with a lowercase letter
        action = [OPTIONS: "getOptions", POST: "saveStuff"]
    }
我使用Grails2.0.3,但它并没有像我预期的那样工作。但应该适用于最新的grails版本(2.3)。请参阅相关信息。

尝试以下代码:

 "/somewhere" (controller: "api", parseRequest: true) { //controller name begins with a lowercase letter
        action = [OPTIONS: "getOptions", POST: "saveStuff"]
    }

我使用Grails2.0.3,但它并没有像我预期的那样工作。但应该适用于最新的grails版本(2.3)。请参阅相关信息。

应该是这样的。我需要更多关于你申请的信息。你能提供你的控制器代码和实际的请求url吗?我已经更新了我的问题,使之更加明确。你能确认这对你真的有效吗?我一到工作岗位就会试试。我需要更多关于你申请的信息。你能提供你的控制器代码和实际的请求url吗?我已经更新了我的问题,使之更加明确。你能确认这对你真的有效吗?我一到我的工作岗位就会试试=)