0

render でマークアップを使用しても、form タグは追加されません。

contentType "text/html", "txt/xml" でこれを試しましたが、うまくいきません。

コントローラーにこれがあります:

 def myTest= {
    render(contentType: "text/plain") {
        div(id:"myDiv") {
            p "somess text inside the div"
            form (action:'get') {
                p "inside form"
            }
        }
    }

そして、私はこれを得ています:

<div id='myDiv'><p>somess text inside the div</p><p>inside form</p></div>

これ欲しい:

<div id='myDiv'><p>somess text inside the div</p><form><p>inside form</p></form></div>

フォームを追加しない理由と追加方法を知っている人はいますか?

ありがとう、

フェデリコ

4

1 に答える 1

2

この問題は以前に発見されており、回避策はビルダーを直接使用することでした

def test = {
    def sw = new StringWriter()
    def b = new MarkupBuilder(sw)
    b.html(contentType: "text/html") {
        div(id: "myDiv") {
            p "somess text inside the div"
            b.form(action: 'get') {
                p "inside form"
            }
        }

    }
    render sw
}

次のHTMLをレンダリングします

<html contentType='text/html'>
  <div id='myDiv'>
    <p>somess text inside the div</p>
    <form action='get'>
      <p>inside form</p>
    </form>
  </div>
</html>
于 2009-10-09T18:10:40.647 に答える