grails - 什么是模板以及如何在gsp中创建模板?

标签 grails

在下面什么是template?我在哪里创建它以及如何使用它?

def RenderDemo = {

    //Render text to response
    render "hellooooo"

    //Render text for specified content type/ encoding
    render (text: "<strong><h1><marquee>Akshay</marquee></h1></strong>" , contentType: "text/html")

    //Render a Template to the response for the specified model...
    def theShining = [title: "The Shining" , auther : "king"]

    render(template: "RenderDemo" , model: [book : theShining])

}

最佳答案

模板是部分GSP或GSP的一部分。它打算被重用。就像任何其他GSP一样,它属于grails-app/views/目录结构。所有模板的文件名都以下划线_开头。因此,在您的示例中,模板为:grails-app/views/render/_renderDemo.gsp

我强烈建议您阅读official documentation on views and templates,它解释了为什么您将使用模板并向您提供有关模板的更多详细信息。

关于grails - 什么是模板以及如何在gsp中创建模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32118080/

相关文章:

grails - 执行自定义验证时如何在 Grails 生成的表单中显示字段错误?

grails - 警报grails分页当前偏移值

sql-server - 使用旧式数据库SQL Server的Grails

grails - 外部化grails中的属性

Grails 构建测试数据

grails intellij ide 'run application' 无法加载任何 Controller

hibernate - 将整个表加载到缓存Grails中

mongodb - 处理请求时发生Grails-MongoDB-IndexOutOfBoundsException

grails - Grails上的MVC架构

grails - 创建自定义验证器