百度下拉框
来源:互联网 发布:windows7 软件中文乱码 编辑:程序博客网 时间:2024/06/03 04:02
jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <script src="js/jquery-1.8.3.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { $("#name").keyup(function(){ document.getElementById("mess").style.display="block"; //$("#mess").attr("display","block"); //alert("1234") $.ajax({ url : "ajaxServlet", //要提交的URL路径 type : "post", //发送请求的方式 data : {ser:$("#name").val()}, //要发送到服务器的数据 dataType : "text", //指定传输的数据格式 success : function(result) {//请求成功后要执行的代码 var arr = result.split(","); //alert("1"); $("#mess").html(""); for(var i=0;i<arr.length;i++){ $("#mess").append("<div class='mouse' onmouseover='mouseover(this);' onmouseout='mouseout(this);' onclick='click1(this);'>"+arr[i]+"</div>"); } }, error : function() { //请求失败后要执行的代码 alert("验证失败!!"); } }); }); }); function mouseover(v){ v.style.backgroundColor="#F4F2F4"; } function mouseout(v){ v.style.backgroundColor="white"; } function click1(v){ var value = v.innerHTML; $("#name").val(value); $("#mess").html(""); } </script> <style type="text/css"> body{width: 1024; } table{margin-top: 50px; width: 70%} tr{height: 50px} .t1{ background-color:#DFFFFF } #name{ width: 400px;} #mess{position: absolute; top: 87px;left: 390px;display: none} </style> </head> <body> <form action=""> <table align="center"> <tr> <td class="t1" width="25%">承租人名称</td> <td class="t1" width="45%"> <input id="name" type="text" > </td> </tr> <tr> <td class="t1" width="25%">友情提示</td> <td class="t1" width="45%"> </td> </tr> <tr> <td class="t1" width="25px">是否锁定</td> <td class="t1" width="45%"> </td> </tr> </table> <div id="mess" style="width: 400px; float: left;"></div> </form> </body></html>
servlet
package com.lq.servlet;import java.io.IOException;import java.sql.ResultSet;import java.util.ArrayList;import java.util.List;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.lq.utils.JdbcUtil;public class AjaxServlet extends HttpServlet { /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); String ser= request.getParameter("ser"); System.out.println(ser); JdbcUtil ju=new JdbcUtil(); String sql="select name,card from t_users t where name like '%"+ser+"%'"; System.out.println(sql); //List list=new ArrayList(); String s=""; try { ResultSet rs=ju.querry(sql, null); while(rs.next()){ System.out.println(rs.getString(1)+"_"+rs.getString(2)+","); s=s+(rs.getString(1)+"_"+rs.getString(2)+","); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } response.getWriter().print(s); }}
阅读全文
0 0
- vue百度下拉框
- vue+百度下拉框
- 百度下拉框
- 采集百度推荐词、百度下拉框
- 像百度一样ajax显示下拉框
- 模拟百度的自动下拉提示框
- Ajax 仿照百度即时下拉框
- 仿百度下拉提示框代码
- 百度搜索下拉框智能提示功能
- 百度搜索下拉框与原理
- 利用jsonp实现百度搜索下拉框
- vuejs 百度下拉框的实验
- 百度下拉框代码 百度推荐词代码
- 百度下拉-纯ajax
- jsonp百度下拉实例
- 百度搜索下拉实现
- 百度搜索下拉效果
- ajax实现类似百度和google的下拉框原理
- php 常用原生函数
- Faster RCNN 代码文件夹说明
- Windows下使用python pymysql查询中文表头MySQL表
- thinkpad如何禁用触摸板(触控板)或指点杆
- python excel文件的append data (不覆盖之添加操作)
- 百度下拉框
- DefaultTableModel
- Spring Boot之Spring Data JPA自定义ID策略
- ARM汇编指令集
- 将springboot项目部署为war项目
- 人工智能国家政策
- 38. Count and Say
- vue全家桶+node+mongodb商城项目小结
- Max Sum问题:c++