SSM框架中没有 There is no getter for property named ‘name’ in ‘class com.itheima.domain.UserVO’
-
翻译成中文的大致意思就是没有名字为name的getter方法在com.itheima.domain.UserVO
-
原因:
UserVO实体类中没有name的方法 而且getter和setter方法都是自动生成的所以不会有字段没有生成getter方法 所以应该是SSM配置信息没有name字段 怎么会有getter方法呢???根本原因就是配置文件中字段配置错误在UserVO中不存在 -
UerVO源码显示
public class UserVO { // 当前页码 private Integer currentPage; // 每页显示条数 private Integer pageSize; // 用户名 private String userName; // 开始时间 @DateTimeFormat(pattern = "yyyy-MM-dd") private Date startCreateTime; // 结束时间 @DateTimeFormat(pattern = "yyyy-MM-dd") private Date endCreateTime; getter setter.....
-
解决方案
-
找到出错的位置(我的方法比较笨)
在web 层打印UserVO实体类/** * 多条件查询 * @param userVO * @return */ @RequestMapping("/findUserCondition") private ResponseResult findUserCondition(@RequestBody UserVO userVO) { System.out.println(userVO); PageInfo userCondition = userService.findUserCondition(userVO); System.out.println(userVO); return new ResponseResult(true,200,"多条件查询成功",userCondition); }
在service层打印UserVO实体类
/** * 多条件查询 * @param userVO * @return */ @Override public PageInfo findUserCondition(UserVO userVO) { System.out.println(userVO); PageHelper.startPage(userVO.getCurrentPage(),userVO.getPageSize()); System.out.println(userVO); List<User> userList = userMapper.findUserCondition(userVO); PageInfo<User> userPageInfo = new PageInfo<>(userList); return userPageInfo; }
运行Tomcat重新发送数据控制台显示如下
再查寻Mabatis对应的配置文件
-