小编Sup*_*iya的帖子

如何在grails中显示html?

我有一个域类,其中包含一个包含HTML代码的字符串变量.我想在myxml.gsp上显示此代码.

为此我写了以下代码:

Learn.groovy

public class Learn {

    String content = ("<html><head><title>Learning Grails</title>
       <body>Grails is fun</body></html>");

}
Run Code Online (Sandbox Code Playgroud)

myxml.gsp

<html>
  <head>
    <title>Xml Output</title>
  </head>
  <body>
     <p>${learn.content}<p> 
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

然而,它无法获取"内容"的值,得到错误:"Cannot get property 'content' on null object".我做错了什么?有没有更好的方法来实现这一目标?

html grails gsp

0
推荐指数
1
解决办法
4955
查看次数

标签 统计

grails ×1

gsp ×1

html ×1