我正在使用spring和hibernate创建一个Q和A站点,我在删除用户时遇到错误......错误状态...... rg.hibernate.QueryException:并非所有命名参数都已设置:[id] [从用户那里删除 user_id =:id ]
此错误已解决,现在供参考,我的代码是....
控制器..........
@RequestMapping(value = "/delete", method = RequestMethod.GET)
public ModelAndView deleteUser(@RequestParam("id") int user_id ) {
userservice.deleteUser(user_id);
return new ModelAndView("jsp/AdminUsers");
}
道…………
public void deleteUser(int user_id) {
User user = (User) sessionFactory.getCurrentSession().load(User.class, user_id);
if(null!=user){
sessionFactory.getCurrentSession().delete(user);
}
}
服务....
public void deleteUser(int user_id) {
userDao.deleteUser(user_id);
}
查看页面网址...
/delete.html?id=${user.user_id}"