【问题标题】:render Grails tag in controller在控制器中渲染 Grails 标签
【发布时间】:2012-09-13 23:23:58
【问题描述】:

我必须在调用控制器函数时呈现一个选择。

class FormController {
    def document() {
        render """<g:select name="tipo" from="${['','one','two']}" />"""
    }
}

它不起作用。当我用这个函数替换一个 div 时,在 html 中什么也没有出现。

【问题讨论】:

    标签: grails controller gsp


    【解决方案1】:

    改用tag as method call 语法:

    render g.select(name:"tipo" from:['','one','two'])
    

    【讨论】:

    • 谢谢:render(text:g.select(name:"tipo" from:['','one','two']))
    【解决方案2】:
    //Build your output string as the next:
    def output = g.select(name:"tipo" from:['','one','two'])
    //And add any other string or tag if you need
    output = "Tipo: " + output
    render (text: output)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-16
      • 2014-05-01
      • 2012-02-28
      • 2012-01-06
      • 1970-01-01
      相关资源
      最近更新 更多