我正在编写一个 grails 应用程序。我使用 withFormat 来呈现结果。这是代码:
class TestController{
def index(){
def result = ["a":"1"]
withFormat {
json{ render result as JSON }
xml{ render result as XML}
}
}
}
我使用 url.../test
和.../test/index.json
and.../test/index
来测试它。它给了我一个HTTP Status 404
错误,并告诉我the requested resource is not available.
我不确定为什么会发生这种情况。