不知道你模糊查询时什么样的的 。比如 你传到前台是 ABCD ,EFG 等
你输入框 是 B ,点击查询 然后 索引到 ABCD。把这填充到结果。
其他特殊的话用正则。简单的话 js index应该可以的。不知道你是否是这种效果
你输入框 是 B ,点击查询 然后 索引到 ABCD。把这填充到结果。
其他特殊的话用正则。简单的话 js index应该可以的。不知道你是否是这种效果
解决方案 »
- IE为什么没办法显示图片呢
- jsp调用的html网页中文是乱码
- 显示用户上次登陆时间。
- Flex和JavaFX我该选哪一种?
- 关于struts中action问题
- jsp无法关闭ORACLE数据库连接!
- MySQL驱动是怎么安装的?谢谢
- Java se, test se
- 求解数据结构一题
- weblogic7下如何部署jsp、servelet?
- webservice客户端调用服务端org.codehaus.xfire.fault.XFireFault: java.lang.NullPointerExce
- Spring框架的methodBeforeAdvice和AfterReturningAdvice问题
先说明你的值是怎么来的?是ajax请求过来的还是request.setAttribute过来前台的?
<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>
先说明你的值是怎么来的?是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的,下半部分都是显示出来
先说明你的值是怎么来的?是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)
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语句中。
<script type="text/javascript">
var obj = {};
obj.lineNo="${item}";
</script>