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")
&
Ïà¹ØÎĵµ£º
JavaÉú³ÉͼƬÑéÖ¤Âë
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.*;
import java.awt.image.*;
import java.util.*;
import javax.imageio.*;
/**
*
* @author http://www.tot.name
* @version
*/
public cl ......
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 ......
Ç°Á½ÌìѧµÄÊÇjavaµÄ»ù´¡ÒÔ¼°ÔõôÅäÖÃJDK
public class Information{
public static void main(String args[]){
System.out.println("ÐÕÃû£º"+"asf");
System.out.println("ÐÔ±ð£º"+"m");
&n ......
from: http://www.leftworld.net/online/java/index.html
<Thinking in java>¸½Â¼C Java±à³Ì¹æÔò
±¾¸½Â¼°üº¬ÁË´óÁ¿ÓÐÓõĽ¨Ò飬°ïÖú´ó¼Ò½øÐеͼ¶³ÌÐòÉè¼Æ£¬²¢ÌṩÁË´úÂë±àдµÄÒ»°ãÐÔÖ¸µ¼£º
(1) ÀàÃûÊ××ÖĸӦ¸Ã´óд¡£×ֶΡ¢·½·¨ÒÔ¼°¶ÔÏ󣨾ä±ú£©µÄÊ××ÖĸӦСд¡£¶ÔÓÚËùÓбêʶ·û£¬ÆäÖаüº¬µÄËùÓе¥´Ê¶¼Ó¦½ô¿¿ÔÚÒ»Æð£ ......
(Ò») ÓйؽéÉܶþ½øÖÆÊý¾ÝÔÚWSÖд«ËÍ,¿ÉÒÔÓÐÁ½ÖÖ·½Ê½:
1 °ÑÊý¾ÝÖ±½Ó×÷ΪxmlÎĵµÖÐijԪËصÄ×Ö½ÚÁ÷,×÷ΪXML½âÎöÆ÷Òª½âÎöµÄÒ»²¿·Ö,ºÜÃ÷ÏÔÕâÖÖ·½Ê½±È½ÏµÍЧ.
2 ¶þ½øÖÆÊý¾Ý×÷Ϊ¸½¼þ,×÷Ϊ´øÍâ(out of band)Êý¾ÝËæͬXML·¢ËÍ, Ìá¸ßÁËЧÂÊ.Ä¿Ç°ÕâÀà´¦ÀíÓм¸¸ö¹æ·¶:DIME(Ö±½Ó Internet ÏûÏ¢·â×°),Õâ¸öÊý¾Ý°ü×°¸ñʽ¼°Æä´¦Àí,Ö»Ó ......