问题描述
对,所以我的测试视图代码是:
@Secured(["IS_AUTHENTICATED_REMEMBERED","IS_AUTHENTICATED_FULLY"])
def list(){
def allPosts = postService.getPosts()
}
<body>
<h1>Welcome to the main feed,<sec:loggedInUserInfo field="username" var="username"/></h2>
<g:if test="${flash.message}">
<div class="messageContainer">
<div style="display: block">${flash.message}</div>
</div>
</g:if>
<p/>
<div>
<g:each var="post" in="${allPosts}">
<p>Last Name: ${post.content}</p>
<p>First Name: ${post.content}</p>
</g:each>
</div>
</body>
</html>
这行得通,
这只是为了测试是否还有其他问题,尽管我希望它解决这个问题:
@Secured(["IS_AUTHENTICATED_REMEMBERED","IS_AUTHENTICATED_FULLY"])
def wall() {
def allPosts = postService.getPosts()
profile = springSecurityService.currentUser.getProfile()
if(!profile){
redirect(controller: "profile",action: "viewProfile")
}else {
[profile: profile]
}
}
和
<!doctype html>
<html>
<head>
<meta name="layout" content="main"/>
</head>
<body>
<h1>Welcome to the main feed,<sec:loggedInUserInfo field="username" var="username"/></h2>
<g:if test="${flash.message}">
<div class="messageContainer">
<div style="display: block">${flash.message}</div>
</div>
</g:if>
<p/>
<div>
<h3>
What are you thinking?
</h3>
</p>
<div>
<g:form action="addPost">
<g:textArea class="postContent" id="postContent" name="content" rows="3" cols="50"/><br/>
<g:submitButton class="postSubmit loginButton" name="post" value="Post"/>
</g:form>
<div>
</div><br/>
<div class="PostContainer">
<g:each var="post" in="${allPosts}">
<p>${post.content}</p>
<p>${post.content}</p>
</g:each>
</div>
</div>
</body>
</html>
但是帖子和内容不会在第二个示例中呈现
还有 postService:
@Transactional
class PostService {
def getPosts() {
[allPosts:Post.list()]
}
}
对此的任何见解将不胜感激。
我使用 Windows 10 和 Chrome 浏览器
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)