上代码:

controller:

@RequestMapping(value = "/findPage", method = RequestMethod.POST)
@ResponseBody
public Object findPage(@RequestParam(required=false) String jobCategory,@RequestParam(required=false) String ids,@RequestParam(required=false) String cities) {
try {
List<Integer> listJob = new ArrayList<Integer>();
List<Integer> listIds = new ArrayList<Integer>();
List<String> listCities = new ArrayList<String>();
//按照城市名称和工种查询
if(StringUtils.isNotBlank(jobCategory) && StringUtils.isNotBlank(cities)){
String[] temp = jobCategory.split(",");
String[] cityTemp = cities.split(",");
for(int i=0;i<temp.length;i++){
listJob.add(Integer.valueOf(temp[i]));
}
for(int i=0;i<cityTemp.length;i++){
listCities.add(cityTemp[i]);
}
List<WebsitesJob> list = jobService.findPage(listJob, listIds, listCities);
return new ExtGridReturn(list.size(), list);
}
//按照工种查询
if(StringUtils.isNotBlank(jobCategory)){
String[] temp = jobCategory.split(",");
for(int i=0;i<temp.length;i++){
listJob.add(Integer.valueOf(temp[i]));
}
}
//按照职位名称查询
if(StringUtils.isNotBlank(ids)){
String[] temp = ids.split(",");
for(int i=0;i<temp.length;i++){
listIds.add(Integer.valueOf(temp[i]));
}
}
//按照城市查询
if(StringUtils.isNotBlank(cities)){
String[] temp = cities.split(",");
for(int i=0;i<temp.length;i++){
listCities.add(temp[i]);
}
}
List<WebsitesJob> list = jobService.findPage(listJob, listIds, listCities);
return new ExtGridReturn(list.size(), list);
} catch (Exception e) {
LOGGER.error("分页获取信息出错", e);
return new ExceptionReturn(e);
}
}

mapper

/**
* 描述:根据工种查询列表
* @param jobCategorys
* @return
*/
List<WebsitesJob> findPage(@Param("jobCategorys") List<Integer> jobCategorys,@Param("ids") List<Integer> ids,@Param("workPlace") List<String> workPlace);

xml

<!-- 前台查询列表 -->
<select id="findPage" resultType="cn.edu.hbcf.plugin.websites.pojo.WebsitesJob">
select n.ID id,
n.NAME name,
n.WORKPLACE workPlace,
n.JOBCATEGORY jobCategory,
n.SALARY salary,
n.RESPONSIBILITIES responsibilities,
n.REQUIREMENTS requirements,
n.ISHOT isHot,
n.UPDATEDATE updateDate,
n.UPDATEUSER updateUser,
u.real_name updateName
from websites_job n
left join base_users u on n.updateUser = u.account
<where>
<if test="jobCategorys.size()!=0">
or n.jobCategory in
<foreach collection="jobCategorys" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="ids.size()!=0">
or n.id in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="workPlace.size()!=0">
or n.WORKPLACE in
<foreach collection="workPlace" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
order by n.ISHOT,n.ID desc
</select>

mybatisforeach循环,传入多个参数的更多相关文章

  1. useEffect传入第二个参数陷入死循环

    最近新项目刚上手,就用了react的hooks,之前也看过hooks的不少文章,只是还没实战实战. 业务场景1:需要在页面一开始时得到一个接口的返回值,取调用另一个接口. 我的思路是,先设置这个接口的 ...

  2. 每日一记-mybatis碰到的疑惑:String类型可以传入多个参数吗

    碰到一个觉得很疑惑的问题,Mybatis的parameterType为String类型的时候,能够接收多个参数的吗? 背景 初学Mybatis的时候,看的教程和书籍上都是在说基本的数据类型如:int. ...

  3. mybatis传入多个参数

    一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...

  4. mybatis从dao传入多个参数到sqlmap时dao中要使用map或实例对象(如:user)作为参数传入, 否则报错找不到属性getter方法

    23:37 2015-07-02 注意1. 使用mybaits的resultMap查询时, 如果想传入多个参数(比如where 1=1动态多条件查询时)sqlmap文件中对应的方法中, selectL ...

  5. Mybatis 接口传入多个参数 xml怎么接收

    mybatis 在接口上传入多个参数 1.如果传入的参数类型一样. Map<String, String> queryDkpayBindBankCidByOriBindAndBankCid ...

  6. 小峰mybatis(2)mybatis传入多个参数等..

    一.mybatis传入多个参数: 前面讲传入多个参数都是使用map,hashmap:key value的形式:-- 项目中开发都建议使用map传参: 比如现在通过两个参数,name和age来查询: 通 ...

  7. postgresql Java JDBC 一次性传入多个参数到 in ( ?) - multple/list parameters

    经常不清楚需要传入多少个参数到 IN () 里面,下面是简单方法: 方法 1 - in ( SELECT * FROM unnest(?)) ) Integer[] ids={1,2,3};      ...

  8. js中的方法如何传入多个参数

    js中的方法如何传入多个参数 $(function () { let parameter1 = 1; let parameter2 = 'Hello World'; let parameter3 = ...

  9. (转)MyBatis传入多个参数的问题

    背景:记录mybaitis的使用方法,博闻强记,后面尽量记忆使用. MyBatis传入多个参数的问题 MyBatis传入多个参数的问题 详细记录mybatis在传递多个参数时候的使用方法 关于Myba ...

  10. MyBatis如何传入多个参数

    一.单个参数 mapper public List<Test> getTestList(String id); xml <select id = "getTestList& ...

随机推荐

  1. hihocoder 1169 猜数字

    传送门 时间限制:10000ms 单点时限:5000ms 内存限制:256MB 描述 你正在和小冰玩一个猜数字的游戏.小冰首先生成一个长为N的整数序列A1, A2, …, AN.在每一轮游戏中,小冰会 ...

  2. linux在线学习

    https://www.shiyanlou.com/courses/running/291#note

  3. vagrant 启动错误

    Stderr: VBoxManage.EXE: error: Failed to create the VirtualBox object!VBoxManage.EXE: error: Code E_ ...

  4. 锋利的jQuery-1-- :的用法

    在一个id为table的表格的tbody中,如果每一行的最后一列的checkbox没有被禁用,则把这行的背景色设置为红色. $( "#table>tbody>tr:has(td: ...

  5. linux crontab介绍

    第1列分钟1-59第2列小时1-23(0表示子夜)第3列日1-31第4列月1-12第5列星期0-6(0表示星期天)第6列要运行的命令 下面是crontab的格式:分 时 日 月 星期 要运行的命令 这 ...

  6. JS实现打字机式字符输出效果

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  7. HttpRuntime应用程序的运行时

    System.Web.HttpRuntime类是整个Asp.net服务器处理的入口. 这个类提供了一系列的静态属性,反映web应用程序域的设置信息,而且每个web应用程序域中存在一个System.We ...

  8. 通过cmd修改注册表并设置cmd窗口的大小

    设置cmd的窗口 mode: modem设置系统设备,主要是lpt1, com1/2, con: 启动时设置窗口大小: cmd /k "mode con: cols=120 lines=40 ...

  9. ubuntu.sh: 113: ubuntu.sh: Syntax error: "(" unexpected

    在ubuntu电脑上安装lnmp环境,执行下面命令时 sudo sh ubuntu.sh 报错误:ubuntu.sh: 113: ubuntu.sh: Syntax error: "(&qu ...

  10. iOS上传应用过程中出现的错误"images contain alpha channels or transparencies"以及解决方案

    如何取消图片透明度  本文永久地址为 http://www.cnblogs.com/ChenYilong/p/3989954.html,转载请注明出处. 当你试图通过<预览>进行" ...