关于sql判断报错问题
<select id="findAll" resultMap="forAll">
select * from student
<if test="major!=null">
where major = #{major}
</if>
</select>
<resultMap id="forAll" type="com.been.Strudent">
<id property="id" column="id"></id>
<collection property="courses" column="id" ofType="com.been.Course" select="getCourses"></collection>
</resultMap>
<select id="getCourses">
select * from course where major_name = #{major}
</select>if(Objects.equals("/findAll",pathStr)){
major = "哲学系";
List<Strudent> all= studentDao.findAll(major);
System.out.println(all);
request.setAttribute("students", all);
request.getRequestDispatcher(request.getContextPath() + "/WEB-INF/all.jsp").forward(request, response);
}public List<Strudent> findAll(@Param("major")String major) {
try {
list = getSqlSession().selectList("findAll",major);
} finally {
SqlSessionUtil.closeSqlSession();
}
return list;
}
1
收起
正在回答 回答被采纳积分+1
相似问题
登录后可查看更多问答,登录/注册
Java数据库开发与实战应用2018版
- 参与学习 人
- 提交作业 277 份
- 解答问题 4297 个
Java数据库开发的必备技能,从流行的MySQL数据库开始,到Java原生的数据库管理接口JDBC的使用,再到常用的数据持久化框架MyBatis,让你向Java工程师的目标又迈进了一步!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星