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

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条回答 默认 最新

相关推荐 更多相似问题