IllegalArgumentException:Bean object must not be null
来源:互联网 发布:淘宝来图定制步骤图片 编辑:程序博客网 时间:2024/05/18 11:23
利用SpringMVC进行添加操作时,因为Employee类里面有个Department类型的属性,所以页面有一句
<form:select path="department.id" items="${departments}" itemValue="id" itemLabel="name"/>
结果这一句提示了IllegalArgumentException:Bean object must not be null,这个异常,此时controller里面的对应的方法为:
@RequestMapping(value="/add",method=RequestMethod.GET)public String addEmplyee(Model model,Emplyee emplyee){model.addAttribute("departments",departmentService.getAllDepartments());model.addAttribute("emplyee",new Emplyee());return "/add";}
我以为是因为department属性初始为null导致的这个异常,便在Employee类的构造方法中加入了一句
department = new Department();
结果还是报这个错,然后我便去上网上搜关于SpringMVC表单的select标签的写法,在确认写法没有问题之后,我又去搜别人controller里面方法的写法,也是类似。
折腾了一个小时左右,我便怀疑是不是${departments}为空。
利用Junit测试了一下,果然为空,想起来因为我昨晚改过department表的列名,而我使用的mybatis,没有修改BaseResultMap,导致查询结果其实确实为空,当然这个问题,可能只是我个人导致的,写这儿只是为了记录下。
之所以修改department表的列名,是因为列名id、name和employee表列名id、name重复了,在mybatis的mapper.xml中,配置级联时,因为列名重复,导致mybatis无法区分属性,会将employee的id和name属性值赋给department,所以我才修改了department表的列名,应该把mapper.xml中的sql语句都相应修改下的,谨记!!
0 0
- IllegalArgumentException:Bean object must not be null
- IllegalArgumentException: view must not be null
- org.springframework.dao.InvalidDataAccessApiUsageException: Bean object must not be null; nested exc
- java.lang.IllegalArgumentException: 'name' must not be null
- Caused by: java.lang.IllegalArgumentException: Original must not be null
- IllegalArgumentException: view must not be null ImageLoader报错
- Bean 'shiroFilter'; nested exception is java.lang.IllegalArgumentException: Bean name must not be em
- [异常整理]java.lang.IllegalArgumentException: Attribute value must not be null
- java.lang.IllegalArgumentException: FacesContext must not be null 错误分析及解决
- 解决 java.lang.IllegalArgumentException: Repository interface must not be null on initialization!
- java.lang.IllegalArgumentException: Object returned from onCreateLoader must not be a non-static inn
- java.lang.IllegalArgumentException: Object returned from onCreateLoader must not be a non-static inn
- Example entity must not be null
- string input must not be null解决办法
- JSON keys must not be null nor the \'null\' string.
- java.lang.IllegalArgumentException: Host name may not be null
- Caused by: java.lang.IllegalArgumentException: Text may not be null
- Target host must not be null /// host name may not be null 处理
- SQL Server native client与sqlcmd单独安装
- 287. Find the Duplicate Number
- 进程地址空间 get_unmmapped_area()
- Linux系统中的mysql创建root用户
- MySQL数据库中的存储过程和函数的操作
- IllegalArgumentException:Bean object must not be null
- (4.6.12.3)Android属性allowBackup安全风险浅析
- JDBC技术总结(一)
- predict.py backup
- 【知乎】我的知乎收藏夹——新奇故(nao)事(dong)篇
- 多线程 happens-before规则
- JavaScript笔记
- utf-8编码格式
- 数据类型的分析理解