SpringBoot的修改操作

Stella981
• 阅读 472

今天学习SpringBoot 的 CRUD 操作,练习 修改操作 时,发生了如下的异常:

[nio-8080-exec-7] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.dao.InvalidDataAccessApiUsageException:
The given id must not be null!; 
nested exception is java.lang.IllegalArgumentException:
The given id must not be null!

出现异常的地址是: http://127.0.0.1:8080/editCategory

修改操作的 控制层的代码是:

//修改
    @RequestMapping("/editCategory")
    public String editCategory(Integer id,Model model) throws Exception{
        System.out.println("---修改----");
        Category category = categoryDao.findOne(id);
        model.addAttribute("category", category);
        return "redirect:editCategory";
    }

把 跳转到指定的页面的代码  即上面的代码中的

return "redirect:editCategory"; 改为 

return "editCategory";

会发生如下的异常:

大致意思是:
这个应用程序没有显式的/Error映射,因此您将其视为一种退步。

出现了一个意外错误(type=Notfind,Status=404)./web-inf/jsp/edtaxy.jsp

原因:

经过一天的排查,找到是修改的方法写错的原因

SpringBoot的修改操作

SpringBoot的修改操作

这里是getOne()方法,而不是findOne()方法。

现在又遇到了另外的一个:

SpringBoot的修改操作

大致意思:

没有可用的消息具体的解决方法:又有了一个错误:

SpringBoot的修改操作

 SpringBoot的修改操作

在这里必须注意的是:

  SpringBoot的修改操作

这两个的名字必须相同,否则就找不到页面;

另外:发生空指针的异常的原因是:

return "redirect:editCategory"; 必须改为  return "editCategory";

SpringBoot的修改操作

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
待兔 待兔
2星期前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Wesley13 Wesley13
2年前
VirtualBox导入已安装好的操作系统的方法
VirtualBox导入已安装好的操作系统的方法1、修改UUID进入VirtualBox安装目录,运行VBoxManage修改UUID,命令运行如下:D:\\VirtualBoxVBoxManage.exe internalcommands setvdiuuid E:\\VirtualX
Stella981 Stella981
2年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Stella981 Stella981
2年前
SpringBoot使用RedisTemplate操作Redis时,key值出现 -xac-xed-x00-x05t-x00-tb
原因分析原因与RedisTemplate源码中的默认序列化方式有关defaultSerializernewJdkSerializationRedisSerializer(classLoader!null?classLoader:this.getClass().getClassLoader()
Easter79 Easter79
2年前
SpringBoot使用RedisTemplate操作Redis时,key值出现 -xac-xed-x00-x05t-x00-tb
原因分析原因与RedisTemplate源码中的默认序列化方式有关defaultSerializernewJdkSerializationRedisSerializer(classLoader!null?classLoader:this.getClass().getClassLoader()
Wesley13 Wesley13
2年前
35岁是技术人的天花板吗?
35岁是技术人的天花板吗?我非常不认同“35岁现象”,人类没有那么脆弱,人类的智力不会说是35岁之后就停止发展,更不是说35岁之后就没有机会了。马云35岁还在教书,任正非35岁还在工厂上班。为什么技术人员到35岁就应该退役了呢?所以35岁根本就不是一个问题,我今年已经37岁了,我发现我才刚刚找到自己的节奏,刚刚上路。
Easter79 Easter79
2年前
SpringBoot的修改操作
今天学习SpringBoot的CRUD操作,练习修改操作时,发生了如下的异常:nio8080exec7.m.m.a.ExceptionHandlerExceptionResolver:ResolvedexceptioncausedbyHandlerexecution:org.springframework.d
Wesley13 Wesley13
2年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
6个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这