在下面什么是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/