如何在Grails3中将gson视图呈现为字符串?
在Grails2中,我们可以将如何在Grails3中将gson视图呈现为字符串?,grails,grails3,Grails,Grails3,在Grails2中,我们可以将GroovyPagerEnder注入到服务或控制器中,并将GSP呈现到字符串中,如中所述 对于Grails3RESTAPI配置文件,我们如何将gson视图呈现为字符串?事实证明它在文档中 @Autowired JsonViewTemplateEngine templateEngine void myMethod() { Template t = templateEngine.resolveTemplate('/book/show')
GroovyPagerEnder
注入到服务或控制器中,并将GSP呈现到字符串中,如中所述
对于Grails3RESTAPI配置文件,我们如何将gson视图呈现为字符串?事实证明它在文档中
@Autowired
JsonViewTemplateEngine templateEngine
void myMethod() {
Template t = templateEngine.resolveTemplate('/book/show')
def writable = t.make(book: new Book(title:"The Stand"))
def sw = new StringWriter()
writable.writeTo( sw )
...
}