small和尚 2017-04-04 09:52 采纳率: 100%
浏览 1453
已采纳

org.hibernate.QueryException]

说是我参数错误但是和数据库都能对上,急,求大神解答
: Expected positional parameter count: 2, actual parameters: [] [select o from Employee o where o.userName=? and o.password=?
@Override
public Employee loginUser(String userName, String password) throws Exception {
String hql = "select o from Employee o where o.userName=? and o.password=?";
List employee = employeeDao.getAll(hql,userName,password);
if (employee.size()>0) {
return employee.get(0);
}
return null;//登录失败
}
这个是service方法
@RequestMapping("/login")
public String login(String userName,String password){
if (userName==null || password==null
|| "".equals(userName) || "".equals(password)) {
return "/login";
}
try {
Employee loginUser = employeeService.loginUser(userName,password);
System.out.println(loginUser);
if (loginUser!=null) {
//�ѵ�½��Ϣ�Ž�session
setSession(LOGIN_USER, loginUser);
}
} catch (Exception e) {
e.printStackTrace();
}
return "/mian";
}
这是个controller方法

  • 写回答

3条回答 默认 最新

  • threenewbee 2017-04-04 11:57
    关注

    employeeDao.getAll的代码怎么写的,里面有没有把后面两个参数传进去

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?