我想通过使用显示用户表中的所有数据NamedParameterJdbcTemplate
,但它不起作用。它显示此错误:
The method query(String, SqlParameterSource, ResultSetExtractor<T>) in the type NamedParameterJdbcTemplate is not applicable for the arguments (String, new RowMapper<User>(){})
报错图片: Dao类报错
DAO code:
private NamedParameterJdbcTemplate jdbc;
@Autowired
public void setDataSource(DataSource jdbc) {
this.jdbc = new NamedParameterJdbcTemplate(jdbc);
}
public List<User> getAllUsers() {
return jdbc.query("select * from user", BeanPropertyRowMapper.newInstance(User.class));
}
服务代码:
public List<User> getAllUsers() {
return userDao.getAllUsers();
}
控制器代码:
@RequestMapping(value="/viewAllUser", method = RequestMethod.GET)
public String viewAllUser(Model model) {
List<User>user = userServices.getAllUsers();
model.addAttribute("user", user);
return "viewAllUser";
}
慕莱坞森
相关分类