【发布时间】:2013-07-07 16:45:17
【问题描述】:
我正在编写一个 grails 应用程序。我使用 withFormat 来呈现结果。代码如下:
class TestController{
def index(){
def result = ["a":"1"]
withFormat {
json{ render result as JSON }
xml{ render result as XML}
}
}
}
我使用网址 .../test 和 .../test/index.json
和.../test/index
来测试一下。它给了我一个HTTP Status 404 错误并告诉我the requested resource is not available.
我不确定为什么会这样。
【问题讨论】:
-
我猜我会说 URL 没有指向文件。三个领先的
.可能是原因。试试../test。 (只有 2 个.) -
您使用哪个版本的 Grails?在 2.2.2 中使用上述(正是您的)控制器实现时,它按预期对我有用。
标签: json url grails http-status-code-404 render