### Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.domain.StudentMappper.selectCountStudent
### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.domain.StudentMappper.selectCountStudent
Mybatis中的xml文件是这样子写的
<!-- 查找列表总数 -->
<select id="Count" resultType="int">
select count(1) from student;
</select>
最好返回类型不能是int,用int就会报以上类型的错,改用为HashMap
@Override
public HashMap<String, String> selectCount() {
//int a = 0 ;
/*Count c=new CountImp();
Connection conn;
try {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_database11","root","123456");
a=c.selectCount(conn);
} catch (SQLException e) {
e.printStackTrace();
}*/
SqlSession session=sqlSessionFactory.openSession();
/* a=session.selectOne("com.domain.StudentMappper.Count");*/
HashMap<String, String> map=new HashMap<String, String>();
String a=String.valueOf(session.selectOne("com.domain.StudentMapper.Count"));
map.put("a", a);
/*a=session.selectMap("map", "com.domain.StudentMappper.selectCountStudent");*/
return map;
}