上代码:

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. __name__和__main的含义

    if __name__ == "__main__": main() This module represents the (otherwise anonymous) scope i ...

  2. 【bzoj2819】 Nim

    www.lydsy.com/JudgeOnline/problem.php?id=2819 (题目链接) 题意 动态树上路径异或和. Solution Nim取石子游戏的sg值就是每堆石子的异或和,所 ...

  3. 数字证书文件格式(cer和pfx)的区别

    作为文件形式存在的证书一般有这几种格式: 1.带有私钥的证书 由Public Key Cryptography Standards #12,PKCS#12标准定义,包含了公钥和私钥的二进制格式的证书形 ...

  4. 我所了解的javaScript细节

    变量转换 var myVar = "3.14159", str = ""+ myVar,// to string int = ~~myVar, // to in ...

  5. 使用Android Studio搭建Android集成开发环境

    有很长一段时间没有更新博客了,最近实在是太忙了,没有时间去总结,现在终于可以有时间去总结一些Android上面的东西了,很久以前写过这篇关于使用Android Studio搭建Android集成开发环 ...

  6. Linux中vi编辑器的用法

    实验一: vi编辑器的模式切换 1.       实验目标:熟练掌握vi编辑器的三种模式间切换及其特点 2.       实验操作步骤: 步骤一: 进入vi编辑器即命令模式 进入vi编辑器可以在命令终 ...

  7. Socket 入门- 客户端回射程序

    结果输出:------------------------------------------------------客户端:xx@xxxxxx:~/Public/C$ ./postBackCli.o ...

  8. derby的三大缺陷

    derby的三大缺陷 derby数据库的嵌入式特性让人很流口水.但是,我刚打算将其用进我的项目中,却发现它没有好的分页查询方式,每次都返回所有符合条件的记录.oracle有rownum,mysql有l ...

  9. Gradle用户指南(3)-构建Java项目

    1.构建基本的Java项目 为了使用 Java 插件,添加下面代码到构建文件: build.gradle apply plugin: 'java' 这个就是 定义一个 Java 项目的全部.它会将 J ...

  10. [bug]使用SharpZipLib遇到中文名称乱码问题

    写在前面 业务逻辑是这样的,需要导出一个app的话题,并需要把该话题下帖子的附件导出,然后需求想修改成人员的名称.jpg的格式.所以就出现了中文乱码的问题.在本地没问题,但发布到服务器上面就出问题,每 ...