【问题标题】:Render a controller into a String将控制器渲染为字符串
【发布时间】:2015-06-17 09:01:32
【问题描述】:

我可以render a template or a view into a String,但是如何将控制器渲染为字符串?

我想做这样的操作:

def myAction = {
  ...
  def html = renderToString(controller: 'myController', action: 'myAction', params: [what:'ever'])
  render modify(html)
  ...
}

【问题讨论】:

    标签: grails grails-2.0


    【解决方案1】:

    您可以为此使用grails include tag

    def html= g.include(controller: 'myController', action: 'myAction', params: [what:'ever'])
    

    【讨论】:

    • 被调用的动作本身必须使用渲染指令,否则会抛出异常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-07
    • 1970-01-01
    • 1970-01-01
    • 2013-02-09
    • 1970-01-01
    • 2018-03-14
    • 2022-01-14
    相关资源
    最近更新 更多