String trainTitle = request.getParameter("trainTitle"); if(StringUtil.isNotEmpty(trainTitle)) { String sql = "select id from aeo_train a where a.train_title like '%"+trainTitle+"%' "; List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql); List<String> list = new ArrayList<String>(); for(Map<String, Object>map:queryForList){ if(map.get("id")!=null){ list.add(map.get("id").toString()); } } String[]s1=list.toArray(new String[0]); if(s1.length>0){ cq.in("trainFid", s1); }else{ String[]s2={"!@#"}; cq.in("trainFid", s2); } }