1、实现IStudentDAOImpl类中的queryStudentByName()函数,代码如下:
![]()
@Override
public List<Student> queryStudentByName(String name) {
List<Student> listStudent = new ArrayList<Student>();
try {
listStudent = sqlMapClient.queryForList("selectStudentByName", name);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return listStudent;
}
2、Student.xml文件中添加代码如下:
![]()
<select id="selectStudendByName" parameterClass="String" resultClass="Student">
Select * from student where sname like '%$sname$%'
</select>
3、main()函数上调用