Last updated by admin 3 years ago
?? ????
????? ?
Grails? JavaServer Pages (JSP) ?? Groovy Server Pages (GSP)? ??? ? ??? ?????. ?????? ? ? ?????. ?? ???? ?????(scriptlet) ??? ??? ??? ?? Groovy? ????? ????! Grails ????? ??(convention mechanism)? ???? ???? ??? ??? ?? ?????. ?? ?? "list"?? ??? ??? "list" ?? ?????:class BookController {
def list = {
["books" : Book.list() ]
}
}<html> <head> <title>Book list</title> </head> <body> <h1>Book list</h1> <table> <tr> <th>Title</th> <th>Author</th> </tr> <g:each in="${books}"> <tr> <td>${it.title}</td> <td>${it.author}</td> </tr> </g:each> </table> </body> </html>
???? ????
????? SiteMesh ? ???? ?? ? ????. ????? ??? ???? ? ??? ????. ???? "layout" ?? ??? ??? ???? ???? ?????:<html>
<head>
<meta name="layout" content="main"></meta>
</head>
<body>This is my content!</body>
</html><html>
<head>
<title><g:layoutTitle default="An example decorator" /></title>
<g:layoutHead />
</head>
<body onload="${pageProperty(name:'body.onload')}">
<div class="menu"><!--my common menu goes here--></menu>
<div class="body">
<g:layoutBody />
</div>
</body>
</html>??? ?? ????
????? ???? ??? ??? "??? ?? ????(layout by convention)" ???. ?? ??, ??? ?? ???? ? ?? ?:class BookController {
def list = { … }
}


