onestarlr / myblog-mybatis Goto Github PK
View Code? Open in Web Editor NEW个人博客系统(SpringBoot+Mybatis)
个人博客系统(SpringBoot+Mybatis)
1、mybatis的xml文件中作者的表用了数据库名修饰了的,即“ 数据库名.表名”。
所有我们要么数据库名字和作者数据库名字一致,要么修改所有xml文件中的sql语句。
2、空指针问题
首页报错空指针:
拆箱时加一个判断,这已经有人说了
类别页面报错空指针:
类型页面不仅显示所有类型,而且还默认显示第一个类型的所有博客,即“types.get(0).getId()”.。但是最初没有任何类型,所以这儿也需要加判断
3、后台登录问题
开始时用户表没有用户,手动添加一个即可,但需要注意密码存储的是MD5加密的,所有需要在单元测试中调用作者的MD5Utils将你的密码转为密文再插入数据库,这样才能正确登录。
总结起来就一个原因:数据库表没有任何示例数据引起的,但也看到了一些考虑不足的细节bug,哈哈。
在编辑分类的名字是,若是编辑后的分类的name在数据库中已经存在,则会提示已重复。但是这个时候正确修改分类名后,是进行新增操作而不是更新操作。原因在于跳转到URL有误。
在controller\admin\TypeController.java文件中。
原来的代码
// 编辑修改分类
@PostMapping("/types/{id}")
public String editPost(@Valid Type type, RedirectAttributes attributes) {
Type type1 = typeService.getTypeByName(type.getName());
if (type1 != null) {
attributes.addFlashAttribute("message", "不能添加重复的分类");
return "redirect:/admin/types/input";
}
int t = typeService.updateType(type);
if (t == 0 ) {
attributes.addFlashAttribute("message", "编辑失败");
} else {
attributes.addFlashAttribute("message", "编辑成功");
}
return "redirect:/admin/types";
}
应修改为新的代码
//查询二级以及所有子集回复
List<Message> findByReplayId(@Param("childId") Long childId);
Replay ≠ Reply
// 运行时间统计 function secondToDate(second)
这里好像有点问题,统计的时间有误,可以因为跨年了 出现了统计数字的错误
重现步骤:
1.初始化数据库数据结构(未初始化数据)
2.直接启动项目
报错如下:
java.lang.NullPointerException: null
at com.star.controller.IndexController.blogMessage(IndexController.java:95)
异常分析:
接口:com.star.service.Impl.BlogServiceImpl#getBlogViewTotal
返回的数据为NULL(如下图),但是 在IndexController.java:95 将其拆箱为int基础类型,于是出现了空指针。
建议: 判断返回结果,当返回为NULL的时候,赋值0。
没有添加这一功能,添加条件搜索后点击上下页按钮,会跳转到没有条件的页数
大大,能给下完整的个人博客系统前后端完整源码吗,想要个全面的学习
src/main/resources/templates/admin/pictures.html
<div class="ten wide column" align="center">
<p>第
<span th:text="${pageInfo.pageNum}"></span> 页,共
<span th:text="${pageInfo.pages}"></span> 页,有
<span th:text="${pageInfo.total}"></span> 个分类
</p>
</div>
此处不应该为分类,应该是图片
重现步骤:
1.初始化数据库数据结构(未初始化数据)
2.直接启动项目
报错如下:
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:458)
at com.star.controller.TypeShowController.types(TypeShowController.java:41)
异常分析:
1.首页点击分类进入
2.由于我本地为初始化数据( 相当于测试环节的边界测试 )
3.查询出来的 types 列表长度( size() ) == 0
4.这个时候,由于该请求来自于首页(id == -1),于是执行 com.star.controller.TypeShowController#types 的
41行 代码 types.get(0),就会抛出该异常。
建议: 判断 types 为空列表的场景。
Request method 'POST' not supported
这个怎么弄,出错了
Exception processing template "index": An error happened during template parsing (template: "class p
网站打开不了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.