我正在将UrlMappings中的某些网址从默认更改为新内容。默认的返回格式是JSON,xxx?format=xml
仍然可以检索XML响应。但是,URI扩展的方法停止工作(xxx.json或xxx.xml),这是我仍然想要的。有没有办法将其重新添加到位?
原创(URI扩展工作):
"/api/companies"(resources:"company") {
"/infos"(resources:"companyInfo")
}
To(URI扩展无效):
"/api/companies"(resources:"company") {
"/info"(controller:"companyInfo", action: 'show', method: 'GET')
"/info"(controller:"companyInfo", action: 'save', method: 'POST')
"/info"(controller:"companyInfo", action: 'update', method: 'PUT')
"/info"(controller:"companyInfo", action: 'delete', method: 'DELETE')
}
答案 0 :(得分:1)
您需要将格式捕获(使用(.$format)?
)添加到URI:
"/api/companies"(resources:"company") {
"/info(.$format)?"(controller:"companyInfo", action: 'show', method: 'GET')
"/info(.$format)?"(controller:"companyInfo", action: 'save', method: 'POST')
"/info(.$format)?"(controller:"companyInfo", action: 'update', method: 'PUT')
"/info(.$format)?"(controller:"companyInfo", action: 'delete', method: 'DELETE')
}