在 grails 中漂亮地打印 XML 响应的最佳方式 [英] Best way to pretty print XML response in grails

查看:25
本文介绍了在 grails 中漂亮地打印 XML 响应的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 grails 操作中给出:

Given this in a grails action:

def xml = {
    rss(version: '2.0') {
        ...
    }
}
render(contentType: 'application/rss+xml', xml)

我看到了:

<rss><channel><title></title><description></description><link></link><item></item></channel></rss>

有没有一种简单的方法可以漂亮地打印 XML?可能是 render 方法中内置的东西?

Is there an easy way to pretty print the XML? Something built into the render method, perhaps?

推荐答案

根据 参考文档,您可以使用以下配置选项启用漂亮打印:

According to the reference docs, you can use the following configuration option to enable pretty printing:

 grails.converters.default.pretty.print (Boolean)
 //Whether the default output of the Converters is pretty-printed ( default: false )

这篇关于在 grails 中漂亮地打印 XML 响应的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆