不知道你模糊查询时什么样的的 。比如 你传到前台是  ABCD ,EFG 等 
你输入框 是  B ,点击查询 然后 索引到 ABCD。把这填充到结果。
其他特殊的话用正则。简单的话 js index应该可以的。不知道你是否是这种效果

解决方案 »

  1.   

    你说的这些在ssh框架中,数据库好像可以自己实现。
      

  2.   

    想补充一下,就是 那些数值已经传到jsp这边了,想要做的就是用一个方法把传过来的值过滤。那个页面是这样的,当进入这个页面时就已经把传过来的值展现出来了,但是太多,所以增加了一个模糊查询,对在这些传过来的值模糊查询过滤,过滤出在查询框里输入的关键字。
      

  3.   

    我这个不是ssh的,所以就想有没有javascript的代码可以实现。
      

  4.   

    能讲一下具体方法吗?或是一些代码,我是刚接触这个的。
    先说明你的值是怎么来的?是ajax请求过来的还是request.setAttribute过来前台的?
      

  5.   

     类似的 <!DOCTYPE html>
    <html>
    <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
    </script>
    <script>
    $(document).ready(function(){
    var data=[];
    data.push("ABCD");
    data.push("TER");
    data.push("EFB");
     $("button").click(function(){
        for(var e in data){
           if(data[e].toString().indexOf($("#searchKey").val())!=-1){
            $("p").append(data[e]+"|");
           }
        }
      }); 
    });
    </script>
    </head>
    <body>
    <input type="text" value="B" id="searchKey"></input>
    <button>search</button>
    <p>data---></p> 
    </body>
    </html>
      

  6.   

    能讲一下具体方法吗?或是一些代码,我是刚接触这个的。
    先说明你的值是怎么来的?是ajax请求过来的还是request.setAttribute过来前台的?
    jsp下边的这一段代码已经把codeView.comments传了过来显示了,现在就是如何通过模糊查询codeView.comments,应该是在jsp写个方法就可以了吧,不必再去弄sql语句和数据库了。
      <%
                      LinkedHashMap hashCodeView=(LinkedHashMap)viewTemplate.get(curTypeView);
                      if (hashCodeView==null) hashCodeView=new LinkedHashMap();
                      Iterator iHashCodeView = hashCodeView.keySet().iterator();
                      while (iHashCodeView.hasNext()) {
                        String viewCode = (String) iHashCodeView.next();
                        CodeViewTable codeView=(CodeViewTable)hashCodeView.get(viewCode);
                         System.out.println("------king-----:"+codeView.comments);
                      %>
      <tr>
    <%
                        String imgName="body_arrow_1.gif";
                        String src="about:blank";
                        if (ViewTool.expFlag(codeView.ctrl_flag).equals("")){
                          imgName="body_arrow_2.gif";
                          src="ViewPage.do?type_view="+curTypeView+"&view_code="+viewCode;
                        }
                        %>
                        <td valign="top">
                          <img id="<%=codeView.view_code%>_img" src="<%=dic.base.tools.TableCommon.path%>images/<%=imgName%>" width="10" height="10" hspace="5" onclick=switchContent(this,'<%=codeView.view_code%>','<%=codeView.type_view%>') style="cursor:hand">
                          <a href="#" Onclick=switchContent(eval("<%=codeView.view_code%>_img"),'<%=codeView.view_code%>','<%=codeView.type_view%>') class="system-switch-bold" ><%=codeView.comments%></a> 
                        </td>
      </tr>
      <tr id="<%=codeView.view_code%>" style="display:<%=ViewTool.expFlag(codeView.ctrl_flag)%>">
    <td valign="top" <%if (!codeView.page_height.equals("")) out.print("height='"+codeView.page_height+"' ");%>>
      <iframe name='view_frame_<%=viewCode%>_list' id='view_frame_<%=viewCode%>_list_id' src="<%=src%>" frameBorder='0' marginwidth='0' marginheight='0' width='100%' height='100%' align='middle' scrolling='auto' onload="style.height=view_frame_<%=viewCode%>_list_id.document.body.scrollHeight">
                          </iframe>
                          <input type="hidden" name="return_flag" value="<%=returnFlag%>">
    </td>
      </tr>
      <tr>
    <td class="line-h-3"><img src="<%=dic.base.tools.TableCommon.path%>images/size.gif" width="1" height="1"></td>
      </tr>
              <%
                      }
                      %> 
    关键是codeView.comments的过滤,这段代码上边的java语句是取出codeView.comments的,下半部分都是显示出来
      

  7.   

    能讲一下具体方法吗?或是一些代码,我是刚接触这个的。
    先说明你的值是怎么来的?是ajax请求过来的还是request.setAttribute过来前台的?
    jsp下边的这一段代码已经把codeView.comments传了过来显示了,现在就是如何通过模糊查询codeView.comments,应该是在jsp写个方法就可以了吧,不必再去弄sql语句和数据库了。
      <%
                      LinkedHashMap hashCodeView=(LinkedHashMap)viewTemplate.get(curTypeView);
                      if (hashCodeView==null) hashCodeView=new LinkedHashMap();
                      Iterator iHashCodeView = hashCodeView.keySet().iterator();
                      while (iHashCodeView.hasNext()) {
                        String viewCode = (String) iHashCodeView.next();
                        CodeViewTable codeView=(CodeViewTable)hashCodeView.get(viewCode);
                         System.out.println("------king-----:"+codeView.comments);
                      %>
      <tr>
    <%
                        String imgName="body_arrow_1.gif";
                        String src="about:blank";
                        if (ViewTool.expFlag(codeView.ctrl_flag).equals("")){
                          imgName="body_arrow_2.gif";
                          src="ViewPage.do?type_view="+curTypeView+"&view_code="+viewCode;
                        }
                        %>
                        <td valign="top">
                          <img id="<%=codeView.view_code%>_img" src="<%=dic.base.tools.TableCommon.path%>images/<%=imgName%>" width="10" height="10" hspace="5" onclick=switchContent(this,'<%=codeView.view_code%>','<%=codeView.type_view%>') style="cursor:hand">
                          <a href="#" Onclick=switchContent(eval("<%=codeView.view_code%>_img"),'<%=codeView.view_code%>','<%=codeView.type_view%>') class="system-switch-bold" ><%=codeView.comments%></a> 
                        </td>
      </tr>
      <tr id="<%=codeView.view_code%>" style="display:<%=ViewTool.expFlag(codeView.ctrl_flag)%>">
    <td valign="top" <%if (!codeView.page_height.equals("")) out.print("height='"+codeView.page_height+"' ");%>>
      <iframe name='view_frame_<%=viewCode%>_list' id='view_frame_<%=viewCode%>_list_id' src="<%=src%>" frameBorder='0' marginwidth='0' marginheight='0' width='100%' height='100%' align='middle' scrolling='auto' onload="style.height=view_frame_<%=viewCode%>_list_id.document.body.scrollHeight">
                          </iframe>
                          <input type="hidden" name="return_flag" value="<%=returnFlag%>">
    </td>
      </tr>
      <tr>
    <td class="line-h-3"><img src="<%=dic.base.tools.TableCommon.path%>images/size.gif" width="1" height="1"></td>
      </tr>
              <%
                      }
                      %> 
    关键是codeView.comments的过滤,这段代码上边的java语句是取出codeView.comments的,下半部分都是显示出来直接用indexOf(String str)
      

  8.   

    是可以用js的正则去做吧,加入输入某个值,用js判断一堆值里面是否有这个值...
      

  9.   

    现在我做这个功能就是在这个jsp里加查询框,查询按钮,点击按钮后,从在查询框里输入的关键字拿来和codeView.comments 过滤也就是你提到的indexof,在 <%
                      LinkedHashMap    
                        hashCodeView=(LinkedHashMap)viewTemplate.get(curTypeView);
                      if (hashCodeView==null) hashCodeView=new LinkedHashMap();
                      Iterator iHashCodeView = hashCodeView.keySet().iterator();
                      while (iHashCodeView.hasNext()) {
                        String viewCode = (String) iHashCodeView.next();
                        CodeViewTable codeView=(CodeViewTable)hashCodeView.get(viewCode);
                         System.out.println("------king-----:"+codeView.comments);
                      %>
    中是取出codeView的java语句,而我点击查询按钮后的取到输入的关键字是个var类型,如何把关键字放到这段java中进行操作? Javascript中的值如何拿到java语句中。
      

  10.   

     你前台怎么显示java 端的数据就怎么用
    <script type="text/javascript">
    var obj = {};
    obj.lineNo="${item}";
    </script>