sql拼接java传集合_利用map格式参数传值,接收拼接sql语句

更新时间:2023-05-14 13:42:26 阅读: 评论:0

sql拼接java传集合_利⽤map格式参数传值,接收拼接sql语句通过将值存⼊map
class="java">
@RequestMapping(value="/list", method = RequestMethod.POST)
@ResponBody
一心一意public Map list(HttpServletRequest request) throws Throwable {蜂蜜会变质吗
String pageNo = Parameter("pager.pageNo");
String pageSize = Parameter("pager.pageSize");
Map map = new HashMap();
String product_name = Parameter("product_name");
if(product_name!=null && !"null".equals(product_name) && !"".equals(product_name)){
map.put("product_name like", "%" + product_name + "%");
}
String basic_ller_name = Parameter("basic_ller_name");
if(basic_ller_name!=null && !"null".equals(basic_ller_name) && !"".equals(basic_ller_name)){
map.put("basic_ller_name like", "%" + basic_ller_name + "%");
}
List> list = productService.findViewByMapPage(map, Integer.parInt(pageNo), Integer.parInt(pageSize));
int total = productService.findViewByMapCount(map);
// 页⾯需要显⽰的列名
String[] column = {
"product_id",
"product_name",
"product_specifications",
"product_short_name",
"product_unit_name",
"basic_ller_name",
"product_sort_name",
"product_brand_name",
"product_image",
"product_origin",
"product_manufacturer",
"product_pinyin",
"product_ll_stop",
"product_buyer_stop",
"product_minus_stock",
"product_barcode_number",
"product_update",
};
安全预案怎么写return Public.listTojson(list, column, pageNo, pageSize, total);
}
sql语句拼接利⽤迭代器将map循环
public List> findViewByMapPage(Map map,
int pageNo, int pageSize) {
StringBuffer sql = new StringBuffer("lect * from " + TableName.product_view);
Iterator it = Set().iterator();
Object object[] = new Object[map.size()];
int i = 0;
if (map.size() > 0) {
while (it.hasNext()) {
男法师Map.Entry entry = (Map.Entry) it.next();
String key = Key().toString();
Object value = Value();
背影怎么画
姓周的历史名人if (i==0) {
sql.append(" where " + key + " ?");
object[i] = value;
} el if (i==1){
sql.append(" and " + key + " ?");
object[i] = value;
}
i++;
}
}
sql.append(" order by product_id desc");
return baDao.String(), object, this.findViewByMapCount(map), pageNo, pageSize, ProductServiceImpl.class);
}
或者sqlpublic List> findViewByMapPage(Map map,
int pageNo, int pageSize) {
议论文怎么写
StringBuffer sql = new StringBuffer("lect * from " + TableName.product_view);
Iterator it = Set().iterator();
Object[] object = new Object[map.size()];
你只在乎你自己int i = 0;
if (map.size() > 0) {
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
String key = Key().toString();
Object value = Value();
sql.append(" where " + key + " ?");
object[i] = value;
i++;
}
}
sql.append(" order by product_id desc");
return baDao.String(), object, this.findViewByMapCount(map), pageNo, pageSize, ProductServiceImpl.class);
}

本文发布于:2023-05-14 13:42:26,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/897400.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:拼接   语句   接收   参数   传值
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图