日期:2014-05-17  浏览次数:20849 次

前台查询关键字
前台form表单代码:
Java code
<form name="" method="post" action="hindexnews_toinfosort.do" style="padding:0px; margin:0px;">

            <ul>
            <li><input type="text" style="width:130px;" class="text_04" id="gq_name" name="gq_name" /></li>
            <li>
                <select class="text_04" style="width:100px;" id="infotype" name="infotype">
                                <option value="0000">---信息类型---</option>
                                <option value="1">供</option>
                                <option value="2">求</option>
                </select>
            </li>
            <li><input type="image" src="<%=path %>/images/dhcx_03.gif" onFocus="this.blur();"></li>
            </ul>
          </form>

action中对应信息代码:
Java code
/***
     * 供求信息类别查询电话
     * @author 
     * @return
     */
    public String toinfosort(){        
        HwebIndexDao dao=new HwebIndexDao();
        inforowgq=hwebindexdao.findsecondinfo();
        typeinfoList=dao.checkalltype(infoid,infotype,gq_name);
        
         if(page!=null){
              currentpage=page;
         }
         fenye=new FenYe(30,typeinfoList.size(),Integer.parseInt(currentpage));
         
        //System.out.println(sortLineList.size());
        return "toinfosort";
    }

dao文件中对应的代码:
Java code
/***
     * 根据动态查询条件查询对应的
     * @param sortid
     * @return
     */
    public List<webInfoBean> checkalltype(String infoid,String infotype,String linename){
        DBUtil dbUtil = new DBUtil();
        List<webInfoBean> list=new ArrayList<webInfoBean>();
        try {
            //动态sql 查询条件生成sql语句
            StringBuilder strsql=new StringBuilder("select * from WEB_INFO where 1=1");            
            if(!SysUtility.isEmptyString(linename)){
                    strsql.append(" and INFO_TITLE like '%"+linename+"%'");
            }
            strsql.append(" order by INFO_ID desc");
            //System.out.println(strsql.toString()+"---------sql-------------");
            dbUtil.createStatement(strsql.toString());
            for(Object o:dbUtil.select(webInfoBean.class,"yyyy-MM-dd")){
                list.add((webInfoBean)o);
            }
        }
        catch (Exception e) {
            log.error("HwebIndexDao.checkSort():", e);
        }
        finally {
            dbUtil.close();
        }        
        return list;
    }

structs中对应 的代码:
Java code
<action name="hindexnews_*" method="{1}" class="com.wfwebsite.action.HindexNewsAction">
<result name="indexsecondinfo">/WEB-INF/homepage/indexSecondInfo.jsp</result>
       <result name="toinfosort">/WEB-INF/homepage/indexSecondInfoCheck.jsp</result>
       </action>





运行代码,搜索功能无法实现。就连只搜索供,或者求得信息都无法显示出来。大虾帮忙看下什么原因呢?

------解决方案--------------------
where 1=1 这里没问题吗?单独运行一下你的sql看看
------解决方案--------------------