ibatis ,.service层方法中,没有配置Student.xml文件中需要的name

 Servlet.service() for servlet Student threw exception
com.ibatis.sqlmap.client.SqlMapException: There is no statement named  in this SqlMap.
 at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:293)
 at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:606)
 at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)
 at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
 at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:298)
 at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
 at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
 at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
 at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:290)
 at pack.java.demo.basedao.BaseDao.queryAll(BaseDao.java:26)

 

 

解决方案:是我在service层,没有配置Student.xml文件中需要的name,也就是别名;
<sqlMap>
<typeAlias alias="Student" type="pack.java.demo.pojos.Student" />
<select id="selectStudentAll" resultClass="Student">
 select * from Student
</select>
 
 public List<Student> queryStudentALl() {
 // TODO Auto-generated method stub
 return studentDao.queryStudentALl(//把这个地方设置为selectStudentAll就行了.就能找到Student.xml文件别名为selectStudentAll这个映射文件了.);
}
  

你可能感兴趣的:(java,xml,orm,ibatis,servlet)