SpringBoot的修改操作

今天学习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

原因:

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

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

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

大致意思:

没有可用的消息
具体的解决方法:

又有了一个错误:

 

 在这里必须注意的是:

  

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

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

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

 


posted @ 2018-02-07 15:51  stujike123456  阅读(1281)  评论(0编辑  收藏  举报