日期:2014-05-17 浏览次数:21042 次
public boolean getStudentsByName(students st) {
System.out.println("验证数据...");
String hql = "from students s where s.name = '" + st.getName() + "'";
List list= this.getHibernateTemplate().find(hql);
System.out.println("共找到数据:" + list.size());
if(list.size() > 0 && list != null) {
return true;
}
return false;
}
public String showStudents() throws Exception {
students st = new students();
if(studentsService.getStudentsByName(st)) {
System.out.println("登录状态:" + studentsService.getStudentsByName(st));
return SUCCESS;
}
return ERROR;
}
jsp:
<form id="form1" name="form1" method="post" action="**.action">
<s:textfield name="name" label="请输入学生姓名:"></s:textfield><s:submit value="搜索"></s:submit>
action:
public String name;
public String showStudents() throws Exception {
if(studentsService.getStudentsByName(name)) {
System.out.println("登录状态:" + studentsService.getStudentsByName(st));
return SUCCESS;
}
return ERROR;
}
geter seter;
service:
public boolean getStudentsByName(String st) {
System.out.println("验证数据...");
String hql = "from students s where s.name = '" + st.getName() + "'";
List list= this.getHibernateTemplate().find(hql);
System.out.println("共找到数据:" + list.size());
if(list.size() > 0 && list != null) {
return true;
}
return false;
}
------解决方案--------------------