#sql("find")
select * from report re
#for(x : cond)
#(for.index == 0? "where" : "and")
#if(x.key=="title")
re.title like concat('%',#para(x.value), '%')
#else
#(x.key) #para(x.value)
#end
#if(x.key=="type")
re.type like concat('%',#para(x.value), '%')
#else
#(x.key) #para(x.value)
#end
#if(x.key=="author")
re.author like concat('%',#para(x.value), '%')
#else
#(x.key) #para(x.value)
#end
#if(x.key=="content")
re.content like concat('%',#para(x.value), '%')
#else
#(x.key) #para(x.value)
#end
#end
#endsql模板就这样,然后就是调用
public void find() {
Record r = getArgsRecord();
HashMap<String, String> cond = new HashMap<String, String>();
if (StrKit.notBlank(r.getStr("title"))) {
cond.put("title",r.getStr("title"));
}
if (StrKit.notBlank(r.getStr("type"))) {
cond.put("type",r.getStr("type"));
}
if (StrKit.notBlank(r.getStr("author"))) {
cond.put("author",r.getStr("author"));
}
if (StrKit.notBlank(r.getStr("content"))) {
cond.put("content",r.getStr("content"));
}
List<Record> list = Db.template("find", cond).find();
System.out.println(list);
renderJson(list);
}然后就是只执行一句sql查询所有,按条件模糊查询的话,一直查出来所有,代码哪里有问题吗,大佬,帮忙看一下
项目:JFinal