Last updated by admin 3 years ago
???????
??????
Grails ????JSP?JavaServer Pages???GSP?Groovy Server Pages?????????????????????????GSP??scriptlet???Groovy?????Java! Grails ??? ??????????????????????? list ??????????"list" ???:class BookController {
@Property 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>
???????Layouts?
????????Grails?SiteMesh?????????????????????????????????"layout"?meta?????????????????<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>?????????????
?????????????????????????? ????class BookController {
@Property list = { … }
}


