SpringMVC在Java中通过jsp显示列表的问题
嗨,我的项目有问题,那是我的帖子。jsp
<!DOCTYPE html>
<html>
<head>
<title>Blog Site-posts</title>
</head>
<body>
<div class="container">
<table class="table table-striped">
<thead>
<tr>
<th>Description</th>
<th>Date</th>
<th>Completed</th>
<th>Written by</th>
</tr>
</thead>
<tbody>
<c:forEach items="${posts}" var="Post">
<tr>
<td>${Post.postId}</td>
<td><fmt:formatDate pattern="dd/MM/yyyy"
value="${post.postDate}" /></td>
<td>${Post.text}</td>
<td>${Post.authorId}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</body>
</html>
那是我的邮政控制器
@Controller
public class PostController {
@Autowired
PostService postService;
@RequestMapping(value="/posts",method = RequestMethod.GET)
public String showPosts(ModelMap model) {
model.addAttribute("posts",postService.findall());
return "posts";
}
}
这是我的博士后课程
public class Post {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int postId;
//@Column(unique=true)
//@NotEmpty
private String title;
//@Column(length=20000)
@Size(max=20000, message="Message cannot be longer than 20000 characters!")
//@NotEmpty
private String text;
private Date postDate;
private int authorId;
我想在jsp中显示带有帖子的列表元素,看看它是如何工作的,但看起来是这样的:
jsp或控制器有什么问题
# 1 楼答案
将此项添加到标记
html
之前的posts.jsp
: