前言:
目前大家对“sql多个like模糊查询”大约比较看重,姐妹们都需要了解一些“sql多个like模糊查询”的相关内容。那么小编同时在网摘上搜集了一些关于“sql多个like模糊查询””的相关文章,希望各位老铁们能喜欢,咱们一起来学习一下吧!话不多说代码呈上:
映射代码
<select id="selectLike" parameterType="hashmap" resultType="com.dhw.vo.TRepoReditList">select * from t_repo_redit_list <where> <if test="map.reportName!=''">and ReporterName like '%${map.reportName}%'</if><if test="map.mediumName!=''">and MediumName like '%${map.mediumName}%'</if></where> limit #{map1.page},#{map1.size}</select> <select id="selectLikeSum" resultType="int">select count(*) from t_repo_redit_list <where> <if test="reportName!=''">ReporterName like '%${reportName}%'</if><if test="mediumName!=''">and MediumName like '%${mediumName}%'</if></where> </select>
dao层代码:
public List<TRepoReditList> selectLike(@Param("map1")Map<String,Integer> map1,@Param("map")Map<String,String> map);public int selectLikeSum(Map<String,String> m);
service层代码:
public List<TRepoReditList> selectLike(Map<String,Integer> map1,Map<String,String> map){ return treporeditDao.selectLike(map1,map); } public int selectLikeSum(Map<String,String> m){ return treporeditDao.selectLikeSum(m); }
controller层代码:
@RequestMapping("LikeReporter.do") public String selectLike(Model m,@RequestParam(defaultValue="1",required=false,value="page")Integer page,String name,String media ){ Map<String,String> map= new HashMap<String, String>(); map.put("reportName", name); map.put("mediumName", media); int sum=treporeditService.selectLikeSum(map); sum=sum%12==0?sum/12:sum/12+1; Map<String,Integer> map1= new HashMap<String, Integer>(); map1.put("page",(page-1)*12); map1.put("size",12); m.addAttribute("repoReditList", treporeditService.selectLike(map1,map)); m.addAttribute("nowpage", page); m.addAttribute("sum", sum); return "/WEB-INF/pages/files/listReporter.jsp"; }
jsp略!!
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。
标签: #sql多个like模糊查询 #jsp中模糊查询