如何做百度输入框智能化搜索?文本框中输入信息查询数据库某一个字段相应的

解决方案 »

  1.   

    难道你说的是搜索提示功能?
    我的资源共享里有我用ajax结合数据库实现的搜索提示功能的例子。
      

  2.   

    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;public class UrlConnect { public static void main(String[] args) {
    new NetWin();
    }}class NetWin extends JFrame implements ActionListener, Runnable {

    JButton button;
    URL url;
    JTextField text;
    JEditorPane area;
    byte b[] = new byte[118];
    Thread thread;
    String URL = "http://www.baidu.com/s?wd=";
    String fin; private Color white; NetWin() {
    text = new JTextField(20);
    area = new JEditorPane();
    button = new JButton("查询");
    button.addActionListener(this);
    thread = new Thread(this);
    JPanel p = new JPanel();
    p.add(new JLabel("连接百度,请输入关键字:"));
    p.add(text);
    p.add(button);
    p.setBackground(white);
    add(area, BorderLayout.CENTER);
    add(p, BorderLayout.NORTH);
    setBounds(60, 60, 600, 400);
    setVisible(true);
    validate();
    } public void actionPerformed(ActionEvent e) {
    if (!(thread.isAlive()))
    thread = new Thread(this);
    try {
    thread.start();
    } catch (Exception ee) {
    text.setText("我正在读取" + url);
    }
    } public void run() {
    try {
    int n = -1;
    area.setText(null);
    area.setVisible(true);
    fin = text.getText();
    URL += fin;
    url = new URL(URL);
    InputStream in = url.openStream();
    while ((n = in.read(b)) != -1) {
    String s = new String(b, 0, n);
    area.setPage(URL);
    }
    } catch (MalformedURLException e1) {
    text.setText("" + e1);
    return;
    } catch (IOException e1) {
    text.setText("" + e1);
    return;
    }
    }}
      

  3.   

    这个是ajax做的技术叫autocomplate
      

  4.   

    楼主到搜索引擎上去搜索一下“Ajax 自动完成”就能找到很多的东西。如果想深入了解的话,建议看看这本书:
      

  5.   

    我想看一个例子java的 不是。net的