public Users loginUser(String username,String password)
{
Users user;
org.hibernate.Transaction tx = session.beginTransaction();
Query q = session.createQuery("from Users as users where Username ="+ username + " && Password = " +password);
user = (Users) q.uniqueResult();
return user;
}
我正在尝试返回尝试登录的用户,但它从调用上述方法的行中给出了错误。
org.apache.jasper.JasperException: An exception occurred processing JSP page /loginlogout.jsp at line 21
堆栈跟踪:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
答案 0 :(得分:0)
我认为您可以尝试以下查询:
Query q = session.createQuery("from Users as users where users.Username=:username and users.Password=:password") ;