初始化后 条件怎么写!!
一个条件判断 因其条件不够严密 查询结果各种奇葩
前台freemarker 传来的参数
[@cms_infoCategory_FlagDirective count='3' recommend_flag='0' show_category=‘1’ ]
后台
定义变量(因需要组合拼接)Action层
String show_category = "";
String show_category_s = "";
String show_compose = "";
String Comma = ",";
String recommend_flag = "";
if ((show_category != null && !show_category.equals(""))
&& (show_category_s != null) && !show_category_s.equals("")) {
show_compose = show_category + Comma + show_category_s;
}
DAOimpl
if(!recommend_flag.equals("")){
f.append(" and (bean.recommend_flag='"+recommend_flag+"')");
}
if(!show_compose.equals(""))
{
f.append(" and (bean.show_category like '%"+show_compose+"%')");
}
DAOimpl中因前段Freemaker传过来的参数初始化为空字符,所有肯定就不是null ,就只需做空字符判断,