zoukankan      html  css  js  c++  java
  • 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";

    
    
  • 相关阅读:
    VS自带的dbghelp.h文件 报错
    Windows 自带的截屏功能
    CentOS 7 安装
    Windows 远程连接 CentOS 7 图形化桌面
    <<、|=、&的小例子
    pip 安装库过慢
    pip -i 和 -U 参数
    windows下安装TA-Lib库
    vector、map 判断某元素是否存在、查找指定元素
    vector push_back报错
  • 原文地址:https://www.cnblogs.com/stujike/p/8426050.html
Copyright © 2011-2022 走看看