首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

前台查询关键字,该如何解决

2012-01-21 
前台查询关键字前台form表单代码:Java codeform name methodpost actionhindexnews_toinfosort.d

前台查询关键字
前台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看看
[解决办法]
Debug一下 看看你那SQL部分的结果

热点排行