struts+hibernate 问题。。
错误:javax.servlet.ServletException: could not execute query
action文件:
public ActionForward execute (ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
IndexForm indexform = new IndexForm();
Session session = HibernateSessionFactory.getSession();
String hql="from welcome i where i.name="+request.getParameter("name")+" and i.password="+request.getParameter("password");
Query query = session.createQuery(hql);
System.out.println(hql);
List list = null;
list = query.list();
System.out.println(list.size());
if(list.isEmpty())
return mapping.findForward("no");
else
return mapping.findForward("ok");
}
奇怪的是我在页面上输入一条数据库里没有的数据他会正确forword到no,如果数据库里有数据他就报could not execute query 错误。请教了。。。。。