grails 休息渲染并返回
有没有办法做到这一点:
def getChannelListJSON = {
def results = Channel2.list()
def t1 = System.currentTimeMillis()
render(contentType:"text/json") {
canais = array {
for(b in results) {
canal = {
id= b.id
nome= b.channel_name
sigla= b.channel_sigla
}
}
}
}
def t2 = System.currentTimeMillis()
def tt = t2 - t1
new Statistic(servico: Servicos.findByName('getChannelListJSON'), totalTime: tt, date: new Date()).save()
}
但我需要使用:而不是使用渲染:
return object as XML
因为我需要将此休息方法与 http://code.google.com/p/grails-jaxrs/wiki/GettingStarted 我无法使用渲染来获取它。
Is there any way to to this:
def getChannelListJSON = {
def results = Channel2.list()
def t1 = System.currentTimeMillis()
render(contentType:"text/json") {
canais = array {
for(b in results) {
canal = {
id= b.id
nome= b.channel_name
sigla= b.channel_sigla
}
}
}
}
def t2 = System.currentTimeMillis()
def tt = t2 - t1
new Statistic(servico: Servicos.findByName('getChannelListJSON'), totalTime: tt, date: new Date()).save()
}
but instead of using render, i need to use :
return object as XML
Because i need to turn this rest method compatible with http://code.google.com/p/grails-jaxrs/wiki/GettingStarted and i cannot ge it using render.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将内容类型更改为“text/xml”
http:// /grails.org/doc/2.0.x/ref/Controllers/render.html
You would need to change the content type to "text/xml"
http://grails.org/doc/2.0.x/ref/Controllers/render.html
尝试:
Try: