SSH 多關鍵字查詢
if (standard.getStandardContent() != null && !standard.getStandardContent().equals("")) {//首先要判斷 你從後臺是否能傳過來
String[] array =standard.getStandardContent().split(" "); //然後 用空格切開 放到數組裡
System.out.println("===============>"+standard.getStandardContent());// 驗證在控制檯
System.out.println("=================+>"+array.length); //
String keyWord = "";
if(array.length==1){
hql += " and s.standardContent like '%" + standard.getStandardContent()+ "%'";
}else{
for(int i = 0; i < array.length; i++){
keyWord = array[i].replace(" ", "");// 替換中英 空格
if (i == 0) {
hql += "and ( s.standardContent like '%" + keyWord + "%'";
}else{
hql += "or s.standardContent like '%" + keyWord + "%'";
}
}
hql += ")" ;
}
}