JavaÀà¼ÓÔØÆ÷
Èç¹ûÄãÏë¶Ôjava¼ÓÔØÀàµÄ»úÖÆÓбȽÏÉîÈëµÄÀí½âµÄ»°,ÇëÄ㻨µãʱ¼äºÃºÃÔĶÁÒ»ÏÂÕâƪ¶«Î÷.
ÕâÀï´ÓÈý¸ö·½Ãæ½²Êöjava classloader
1,½«´ÓwebÓ¦Óóö·¢Ä£ÄâÒ»ÏÂwebÓ¦ÓõÄclassloader(Õâ½ÚÊÇÖصã)
2,ͨ¹ý²âÊÔ2ʵÏÖµÄclassloaderÀ´¼ÓÉîÀí½â
3,·ÒëÒ»ÏÂclassloaderµÄÏà¹Ø¼¼ÊõÎÄÕÂ(À´×ÔCore JavaµÚ¶þ¾íµÄChapter 9. Security),ÓÉÓÚÎÒµÄÓ¢ÎÄˮƽÓÐÏÞ,ÄÑÃâÓв»ºÏÊÊ,Çë´ó¼ÒÖ¸³ö.
¿´¿´ÔõôʵÏÖÒ»¸ö×Ô¼ºµÄClassLoader£¨ÎÒÃÇÒÔwebÓ¦ÓõÄclassloaderΪÀýÀ´½²½â £©
´ó¼Ò¶¼ºÜÊìϤtomcat,±ÈÈçÎÒÃÇҪдһ¸öservletÔËÐеĻ°.
1,ÎÒÃÇͨ³£»áÔÚtomcatµÄwebappsĿ¼Ï½¨Ò»¸ö×Ô¼ºµÄwebĿ¼(±ÈÈçmyweb),È»ºóÈÃ×Ô¼ºµÄmywebÖÁÉÙ¾ßÓÐÒÔÏÂĿ¼½á¹¹.
©¸©¤WEB-INF
©À©¤classes
©¸©¤lib
2,Ö±½Ó°ÑclassÎļþ¿½±´µ½classesĿ¼ÏÂ,»òÕß°Ñ×Ô¼º×öµÄservet´ò³Éjar·Åµ½libÏÂ
3,Æô¶¯tomcat¾ÍÄÜ·ÃÎÊservletÁË.
ÔÙ˵һµã:²»ÉÙÈËÁ˽âstruts,Ò²×ö¹ý»ùÓÚstrutsµÄÓ¦ÓÃ.Æäʵstruts¶ÔÓÚÎÒÃÇÀ´ËµÖ»ÊǼ¸¸öjar¶øÒÑ,ÎÒÃÇÒªÔÚ×Ô¼ºµÄÓ¦ÓÃÖÐÓÃstruts,
Ö»²»¹ý¾ÍÏóÉÏÃæÒ»Ñù°ÑstrutsµÄ¸÷¸ölib¿½±´µ½webÓ¦ÓõÄWEB-INF/libϾÍOKÁË.
ÔÙ×ÛºÏÇ°ÃæµÄ»ù´¡²¿·Ö,ÆäʵwebÓ¦ÓÃÊÇÓÐ×Ô¼ºµÄclassloaderµÄ,ËûרߺÔð¼ÓÔØWEB-INF/libºÍWEB- INF/classesµÄÀà¡£ÏÂÃæÎÒÃǾÍÀ´Ä£ÄâÒ»ÏÂwebÓ¦ÓõÄclassloader,ÏàÐÅ¿´ÁËÏÂÃæµÄ´úÂëÄã¾Í»á¶ÔclassloaderµÄÀí½âÓÖÉÏÒ»¸ǫ̈½×.
view plaincopy to clipboardprint?
import java.io.File;
import java.io.FilenameFilter;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
/*
* webÓ¦ÓõÄclassloader
* ´øÄã²½ÈëclassloaderµÄÌìÌÃ
*/
public class WebAppClassLoader{
URLClassLoader myClassLoader = null;
/*
* Ó÷¨:new WebAppClassLoader(webRoot)
* ±ÈÈç:new WebAppClassLoader("c:/web")
&
Ïà¹ØÎĵµ£º
¼¯ºÏCollection½Ó¿Ú
--Collection ÊÇÈκζÔÏó×飬ԪËظ÷×Ô¶ÀÁ¢£¬Í¨³£ÓµÓÐÏàͬµÄÌ×ÓùæÔò¡£Set ListÓÉËüÅÉÉú¡£
»ù±¾²Ù×÷ Ôö¼ÓÔªËØadd(Object obj); addAll(Collection c);
ɾ³ýÔªËØ remove(Object obj); removeAll(Collection c);
Çó½»¼¯ retainAll(Collection c);
ɾ³ýÔªËØ remove(Object obj); removeAll(Collectio ......
java HTMLÎļþÎĵµ±à¼Æ÷ ʹÓà JTextPane
/* HTMLDocumentEditor.java
* @author: Charles Bell
* @version: May 27, 2002
*/
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
im ......
//java½âÎö.mdbÎļþµÄ±íÃû¼¯ºÏ
this.tableList.clear();
conn = null;
st = null;
rs = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+dbName;// ......
package com.dongyang;
/*
* ¶Áxlsдxml
*/
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
imp ......
1¡¢ ¶ÔÏóµÄ³õʼ»¯
(1) ·Ç¾²Ì¬¶ÔÏóµÄ³õʼ»¯
ÔÚ´´½¨¶ÔÏóʱ£¬¶ÔÏóËùÔÚÀàµÄËùÓÐÊý¾Ý³ÉÔ±»áÊ×ÏȽøÐгõʼ»¯¡£
»ù±¾ÀàÐÍ£ºintÐÍ£¬³õʼ»¯Îª0¡£
Èç¹ûΪ¶ÔÏó£ºÕâЩ¶ÔÏó»á°´Ë³Ðò³õʼ»¯¡£
¡ùÔÚËùÓÐÀà³ÉÔ±³õʼ»¯Íê³ÉÖ®ºó£¬²Åµ÷Óñ¾ÀàµÄ¹¹Ôì·½·¨´´½¨¶ÔÏó¡£
¹¹Ôì·½·¨µ ......