【发布时间】:2012-04-02 06:20:25
【问题描述】:
我正在尝试在 grails 应用程序中构建一个非常简单的 CMS 功能。 基本上我在这里尝试的是在字符串中有一个 gsp,我想从这个字符串构建 gsp。
它可以工作,但生成的页面没有用主布局装饰。 此外,在其他一些尝试中,我注意到传递给 make 方法的模型被忽略了。
我正在使用 grails 2.0.1。
谢谢
class HomeController {
def groovyPagesTemplateEngine
def cms() {
def page = """<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main"/>
<title>CMS page using your application's main layout</title>
</head>
<body>
CMS page using your application's "main" layout.
</body>
</html>"""
StringWriter sw = new StringWriter()
PrintWriter pw = new PrintWriter(sw)
groovyPagesTemplateEngine.createTemplate(page, "somepage.gsp").make([nome: "ciao"]).writeTo(pw)
render sw
}
【问题讨论】:
-
你确定要试试这个吗?你见过 Weceem weceem.org 它与 Grails 的集成非常好...
-
你是对的。我检查了它,但我想在这里实现的是让这个实验发挥作用。与此同时,我会试试 weceem,因为到目前为止我听到了很多好消息
标签: grails content-management-system