当前位置: 技术问答>java相关
急!急!急!请教个位大哥,jsp怎么实现站内搜索? (一定给分)
来源: 互联网 发布时间:2015-09-07
本文导语: 谢谢! | 可以写一个applet,大致代码如下,你自己修改吧: package mshtang.applet; import java.applet.Applet; import java.applet.AppletContext; import java.awt.*; import java.io.*; import java.net.MalformedURLException; import...
谢谢!
|
可以写一个applet,大致代码如下,你自己修改吧:
package mshtang.applet;
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
/**
*
*
*
*
* @author 小唐蔡
* @version 1.0
*/
public class Search extends Applet implements Runnable
{
public Search()
{
criteria = "或";
nofollow = false;
linksonly = false;
forwardonly = false;
}
public void stop()
{
if(th != null)
{
try
{
th.yield();
}
catch(Exception _ex) { }
th = null;
}
}
public void destroy()
{
th = null;
}
public void init()
{
getAllParameters();
try
{
firsturl = new URL(getDocumentBase(), indexpage);
baseurl = getBase(firsturl.toString());
}
catch(Exception _ex) { }
allUrls = new Vector();
urls = new Vector();
paired = new Hashtable();
entitys = new Hashtable(htmlEntitys.length * 2);
loadEntitys(htmlEntitys, entitys);
label1 = new Label();
label2 = new Label();
checkbox1 = new Checkbox();
checkbox2 = new Checkbox();
checkbox3 = new Checkbox();
textField1 = new TextField();
button1 = new Button();
list1 = new java.awt.List();
p = new Panel();
p.setLayout(new BorderLayout());
setLayout(null);
setBackground(new Color(appletbg));
textField1.setBackground(new Color(textfieldbg));
textField1.setForeground(new Color(textfieldfg));
label1.setForeground(new Color(labelfg));
label1.setBackground(new Color(labelbg));
label1.setFont(new Font(labelfont, 1, labelfontsize));
label1.setText(labeltext.trim());
label2.setBackground(new Color(checkboxbg));
label2.setForeground(new Color(checkboxfg));
label2.setFont(new Font(appletfont, 0, appletfontsize));
label2.setText(checkboxtext1);
checkbox1.setBackground(new Color(checkboxbg));
checkbox1.setForeground(new Color(checkboxfg));
checkbox1.setFont(new Font(appletfont, 0, appletfontsize));
checkbox1.setLabel(checkboxtext2);
checkbox1.setState(true);
checkbox2.setBackground(new Color(checkboxbg));
checkbox2.setForeground(new Color(checkboxfg));
checkbox2.setFont(new Font(appletfont, 0, appletfontsize));
checkbox2.setLabel(checkboxtext3);
checkbox3.setBackground(new Color(checkboxbg));
checkbox3.setForeground(new Color(checkboxfg));
checkbox3.setFont(new Font(appletfont, 0, appletfontsize));
checkbox3.setLabel(checkboxtext4);
button1.setBackground(new Color(buttonbg));
button1.setForeground(new Color(buttonfg));
button1.setLabel(buttontext1);
list1.setForeground(new Color(listfg));
list1.setBackground(new Color(listbg));
label1.setBounds(labelx, labely, labelwidth, labelheight);
label2.setBounds(chbox1x, chbox1y, chbox1width, chbox1height);
checkbox1.setBounds(chbox2x, chbox2y, chbox2width, chbox2height);
checkbox2.setBounds(chbox3x, chbox3y, chbox3width, chbox3height);
checkbox3.setBounds(chbox4x, chbox4y, chbox4width, chbox4height);
textField1.setBounds(txtfieldx, txtfieldy, txtfieldwidth, txtfieldheight);
button1.setBounds(buttonx, buttony, buttonwidth, buttonheight);
p.setBounds(listx, listy, listwidth, listheight);
list1.setSize(listwidth, listheight);
p.add("Center", list1);
add(label1);
add(textField1);
add(label2);
add(checkbox1);
add(checkbox2);
add(checkbox3);
add(button1);
add(p);
try
{
System.out.println("nn 站内检索小程序。nCopyright (c) 2002 厦门一方软件公司,nhttp://www.efound.com.cnn");
return;
}
catch(Exception _ex)
{
return;
}
}
package mshtang.applet;
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
/**
*
Title: Search
*
Description: 用于站内搜索的Java小程序
*
Copyright: 一方公司版权所有Copyright (c) 2002
*
Company: 厦门一方软件公司
* @author 小唐蔡
* @version 1.0
*/
public class Search extends Applet implements Runnable
{
public Search()
{
criteria = "或";
nofollow = false;
linksonly = false;
forwardonly = false;
}
public void stop()
{
if(th != null)
{
try
{
th.yield();
}
catch(Exception _ex) { }
th = null;
}
}
public void destroy()
{
th = null;
}
public void init()
{
getAllParameters();
try
{
firsturl = new URL(getDocumentBase(), indexpage);
baseurl = getBase(firsturl.toString());
}
catch(Exception _ex) { }
allUrls = new Vector();
urls = new Vector();
paired = new Hashtable();
entitys = new Hashtable(htmlEntitys.length * 2);
loadEntitys(htmlEntitys, entitys);
label1 = new Label();
label2 = new Label();
checkbox1 = new Checkbox();
checkbox2 = new Checkbox();
checkbox3 = new Checkbox();
textField1 = new TextField();
button1 = new Button();
list1 = new java.awt.List();
p = new Panel();
p.setLayout(new BorderLayout());
setLayout(null);
setBackground(new Color(appletbg));
textField1.setBackground(new Color(textfieldbg));
textField1.setForeground(new Color(textfieldfg));
label1.setForeground(new Color(labelfg));
label1.setBackground(new Color(labelbg));
label1.setFont(new Font(labelfont, 1, labelfontsize));
label1.setText(labeltext.trim());
label2.setBackground(new Color(checkboxbg));
label2.setForeground(new Color(checkboxfg));
label2.setFont(new Font(appletfont, 0, appletfontsize));
label2.setText(checkboxtext1);
checkbox1.setBackground(new Color(checkboxbg));
checkbox1.setForeground(new Color(checkboxfg));
checkbox1.setFont(new Font(appletfont, 0, appletfontsize));
checkbox1.setLabel(checkboxtext2);
checkbox1.setState(true);
checkbox2.setBackground(new Color(checkboxbg));
checkbox2.setForeground(new Color(checkboxfg));
checkbox2.setFont(new Font(appletfont, 0, appletfontsize));
checkbox2.setLabel(checkboxtext3);
checkbox3.setBackground(new Color(checkboxbg));
checkbox3.setForeground(new Color(checkboxfg));
checkbox3.setFont(new Font(appletfont, 0, appletfontsize));
checkbox3.setLabel(checkboxtext4);
button1.setBackground(new Color(buttonbg));
button1.setForeground(new Color(buttonfg));
button1.setLabel(buttontext1);
list1.setForeground(new Color(listfg));
list1.setBackground(new Color(listbg));
label1.setBounds(labelx, labely, labelwidth, labelheight);
label2.setBounds(chbox1x, chbox1y, chbox1width, chbox1height);
checkbox1.setBounds(chbox2x, chbox2y, chbox2width, chbox2height);
checkbox2.setBounds(chbox3x, chbox3y, chbox3width, chbox3height);
checkbox3.setBounds(chbox4x, chbox4y, chbox4width, chbox4height);
textField1.setBounds(txtfieldx, txtfieldy, txtfieldwidth, txtfieldheight);
button1.setBounds(buttonx, buttony, buttonwidth, buttonheight);
p.setBounds(listx, listy, listwidth, listheight);
list1.setSize(listwidth, listheight);
p.add("Center", list1);
add(label1);
add(textField1);
add(label2);
add(checkbox1);
add(checkbox2);
add(checkbox3);
add(button1);
add(p);
try
{
System.out.println("nn 站内检索小程序。nCopyright (c) 2002 厦门一方软件公司,nhttp://www.efound.com.cnn");
return;
}
catch(Exception _ex)
{
return;
}
}
|
使用数据库的全文检索功能。