中国建设银行舟山分行网站,wordpress上传sh文件,佛山企业网站自助建站,建设网站能赚钱吗目录 场景#xff1a;
问题分析#xff1a;
问题解决#xff1a; 场景#xff1a;
简单讲一下应用场景
我拿到一个项目#xff0c;完成后端数据处理#xff0c;在进行可选条件查询时#xff0c;使用动态sql 在mapper.xml中我先是这么写的
select idlist
问题分析
问题解决 场景
简单讲一下应用场景
我拿到一个项目完成后端数据处理在进行可选条件查询时使用动态sql 在mapper.xml中我先是这么写的
select idlist resultTypecom.yizhi.student.domain.StudentInfoDOselect * from s_student_infowhereif testname!nullstudent_name like concat(%,#{name},%)/ifif testtocollegeId!nulland tocollege#{tocollegeId}/ifif testtomajorId!nulland tomajor#{tomajorId}/ifif testclassId!nulland class_id#{classId}/if/wherelimit #{currPage},#{pageSize}/select 然后就出现if标签失效的情况关键是它有时候也会返回到前端数据给我都搞蒙了
反复查看加上网搜索类似案例
大致知道是什么原因
问题分析
在前端向后端传递数据时不一定传递的是null也会是空字符串。
果然在加上判断后可以执行if
问题解决
select idlist resultTypecom.yizhi.student.domain.StudentInfoDOselect * from s_student_infowhereif testname!null and name!student_name like concat(%,#{name},%)/ifif testtocollegeId!null and tocollegeId!and tocollege#{tocollegeId}/ifif testtomajorId!null and tomajorId!and tomajor#{tomajorId}/ifif testclassId!null and classId!and class_id#{classId}/if/wherelimit #{currPage},#{pageSize}/select