博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
仿牛客社区项目3.3——帖子详情(普通功能)
阅读量:2055 次
发布时间:2019-04-28

本文共 1057 字,大约阅读时间需要 3 分钟。

在这里插入图片描述

根据帖子的主键id查询贴子的详情内容。
DiscussPostMapper接口

DiscussPost selectDiscussPostById(int id);

discusspost-mapper.xml

DiscussPostService

public DiscussPost findDiscussPostById(int id) {
return discussPostMapper.selectDiscussPostById(id);}

DiscussPostController

@RequestMapping(path = "/detail/{discussPostId}", method = RequestMethod.GET)public String getDiscussPost(@PathVariable("discussPostId") int discussPostId, Model model) {
// 帖子 DiscussPost post = discussPostService.findDiscussPostById(discussPostId); model.addAttribute("post", post); // 作者 User user = userService.findUserById(post.getUserId()); model.addAttribute("user", user); return "/site/discuss-detail";}

index.html,改超链接。| |是常量和变量拼接的。取帖子主键用${map.post.id}

th:href="@{|/discuss/detail/${map.post.id}|}"

discuss-detail.html,改动态标题、头像、用户名、发帖时间、帖子内容

th:utext="${post.title}"th:src="${user.headerUrl}"th:utext="${user.username}"th:text="${#dates.format(post.createTime,'yyyy-MM-dd HH:mm:ss')}"th:utext="${post.content}"

转载地址:http://nsnlf.baihongyu.com/

你可能感兴趣的文章
除了 k8s,留给 k 和 s 中间的数字不多了!
查看>>
使用 wrk 压测并精细控制并发请求量
查看>>
Ceph 故障排查笔记 | 万字经验总结
查看>>
使用 Go 从零开始实现 CNI 可还行?
查看>>
KubeSphere 3.1.0 GA:混合多云走向边缘,让应用无处不在
查看>>
Containerd 1.5 发布:重磅支持 docker-compose!
查看>>
基于 Kubernetes 的 Spring Could 微服务 CI/CD 实践
查看>>
5.15 相约上海!2021 年度首届云原生 Meetup | KubeSphere & Friends
查看>>
使用 Cilium 作为网络插件部署 K8s + KubeSphere
查看>>
万变不离其宗,性能优化也有章可循
查看>>
别再乱用 Prometheus 联邦了,分享一个 Prometheus 高可用新方案
查看>>
Litmus 实践:让群魔在混沌中乱舞,看 K8s 能撑到何时
查看>>
Prometheus 存储层的演进
查看>>
Kubernetes 边缘节点抓不到监控指标?试试这个方法!
查看>>
不对全文内容进行索引的 Loki 到底优秀在哪里
查看>>
太强大了!这些 Go 的难点问题都能解决!
查看>>
万字长文:K8s 创建 pod 时,背后到底发生了什么?
查看>>
后云原生时代,Kubernetes:你看我还有机会吗?
查看>>
Wintun:一款惊艳的 WireGuard 虚拟网卡接口驱动
查看>>
个人学习方法分享
查看>>