42 lines
735 B
Markdown
42 lines
735 B
Markdown
# 帖子详情页
|
|
|
|
---
|
|
|
|
## DAO
|
|
|
|
## Service
|
|
|
|
## Controller
|
|
|
|
```java
|
|
/**
|
|
* 进入帖子详情页
|
|
* @param discussPostId
|
|
* @param model
|
|
* @return
|
|
*/
|
|
@GetMapping("/detail/{discussPostId}")
|
|
public String getDiscussPost(@PathVariable("discussPostId") int discussPostId, Model model) {
|
|
// 帖子
|
|
DiscussPost discussPost = discussPostSerivce.findDiscussPostById(discussPostId);
|
|
model.addAttribute("post", discussPost);
|
|
// 作者
|
|
User user = userService.findUserById(discussPost.getUserId());
|
|
model.addAttribute("user", user);
|
|
|
|
return "/site/discuss-detail";
|
|
|
|
}
|
|
```
|
|
|
|
## 前端
|
|
|
|
```html
|
|
<span th:utext="${post.title}"></span>
|
|
|
|
<div th:utext="${user.username}"></div>
|
|
|
|
<div th:utext="${post.content}"></div>
|
|
```
|
|
|