这个是controller下的index方法中代码,查询数据
这两个是实体类User用户和Post文章
用了test测试代码没问题,
以下是页面代码
#{extends 'main.html' /}
#{set title:'Home' /}
#{if frontPost}
${frontPost.title}
by ${frontPost.author.fullname}
${frontPost.postedAt.format('MMM dd')}
|
${frontPost.comments.size() ?: 'no'}
comment${frontPost.comments.size().pluralize()}
#{if frontPost.comments}
, latest by ${frontPost.comments[-1].author}
#{/if}
${frontPost.content.nl2br()}
#{if olderPosts}
<div class="older-posts">
<h3>Older posts <span class="from">from this blog</span></h3>
#{list items:olderPosts, as:'oldPost'}
<div class="post">
<h2 class="post-title">
<a href="#">${oldPost.title}</a>
</h2>
<div class="post-metadata">
<span class="post-author">
by ${oldPost.author.fullname}
</span>
<span class="post-date">
${oldPost.postedAt.format('dd MMM yy')}
</span>
<div class="post-comments">
${oldPost.comments.size() ?: 'no'}
comment${oldPost.comments.size().pluralize()}
#{if oldPost.comments}
- latest by ${oldPost.comments[-1].author}
#{/if}
</div>
</div>
</div>
#{/list}
</div>
#{/if}
#{/if}
#{else}
There is currently nothing to read here.
#{/else}
问下各位哪里错误了