【发布时间】:2013-06-15 23:02:00
【问题描述】:
我正在尝试使用自定义 contentType 在 Grails 中呈现响应文本。我想要的 contentType 是:application/vnd.api+json
我正在测试以下内容
render(contentType: "application/vnd.api+json") {
message = 'some text'
foo = 'bar'
}
它不会呈现抛出异常消息是缺少的属性。
虽然以下工作正常:
render(contentType: "text/json") {
message = 'some text'
foo = 'bar'
}
我的 Config.groovy 在 json mime.type 下有以下内容:
grails.mime.types = [
...
json: [
'application/json',
'text/json',
'application/vnd.api+json'
],
...
]
我的问题,如何在 Grails 中使用自定义 mime-type 进行渲染?
【问题讨论】:
标签: grails mime-types content-type