java·´Éä»úÖÆ
JAVA·´Éä»úÖÆ
JAVA·´Éä»úÖÆÊÇÔÚÔËÐÐ״̬ÖУ¬¶ÔÓÚÈÎÒâÒ»¸öÀ࣬¶¼Äܹ»ÖªµÀÕâ¸öÀàµÄËùÓÐÊôÐԺͷ½·¨£»¶ÔÓÚÈÎÒâÒ»¸ö¶ÔÏ󣬶¼Äܹ»µ÷ÓÃËüµÄÈÎÒâÒ»¸ö·½·¨£»ÕâÖÖ¶¯Ì¬»ñÈ¡µÄÐÅÏ¢ÒÔ¼°¶¯Ì¬µ÷ÓöÔÏóµÄ·½·¨µÄ¹¦ÄܳÆÎªjavaÓïÑԵķ´Éä»úÖÆ¡£
Java·´Éä»úÖÆÖ÷ÒªÌṩÁËÒÔϹ¦ÄÜ£º ÔÚÔËÐÐʱÅжÏÈÎÒâÒ»¸ö¶ÔÏóËùÊôµÄÀࣻÔÚÔËÐÐʱ¹¹ÔìÈÎÒâÒ»¸öÀàµÄ¶ÔÏó£»ÔÚÔËÐÐʱÅжÏÈÎÒâÒ»¸öÀàËù¾ßÓеijÉÔ±±äÁ¿ºÍ·½·¨£»ÔÚÔËÐÐʱµ÷ÓÃÈÎÒâÒ»¸ö¶ÔÏóµÄ·½·¨£»Éú³É¶¯Ì¬´úÀí¡£
1. µÃµ½Ä³¸ö¶ÔÏóµÄÊôÐÔ
1 public Object getProperty(Object owner, String fieldName) throws Exception {
2 Class ownerClass = owner.getClass();
3
4 Field field = ownerClass.getField(fieldName);
5
6 Object property = field.get(owner);
7
8 return property;
9 }
Class ownerClass = owner.getClass()£ºµÃµ½¸Ã¶ÔÏóµÄClass¡£
Field field = ownerClass.getField(fieldName)£ºÍ¨¹ýClassµÃµ½ÀàÉùÃ÷µÄÊôÐÔ¡£
Object property = field.get(owner)£ºÍ¨¹ý¶ÔÏóµÃµ½¸ÃÊôÐÔµÄʵÀý£¬Èç¹ûÕâ¸öÊôÐÔÊǷǹ«Óеģ¬ÕâÀï»á±¨IllegalAccessException¡£
2. µÃµ½Ä³¸öÀàµÄ¾²Ì¬ÊôÐÔ
1 public Object getStaticProperty(String className, String fieldName)
2 throws Exception {
3 Class ownerClass = Class.forName(className);
4
5 Field field = ownerClass.getField(fieldName);
6
7 Object property = field.get(ownerClass);
8
9 return property;
10 }
Class ownerClass = Class.forName(className) £ºÊ×Ïȵõ½Õâ¸öÀàµÄClass¡£
Field field&n
Ïà¹ØÎĵµ£º
¹Ø¼ü×Ö: java¶àÏß³ÌÀý×Ó
µ½ÕâÀïÎÒÃÇ×öÒ»¸öÍêÕûµÄÀý×ÓÀ´ËµÃ÷Ï̲߳úÉúµÄ·½Ê½²»Í¬¶øÉú³ÉµÄÏ̵߳ÄÇø±ð£º
package debug;
import java.io.*;
import java.lang.Thread;
class MyThread extends Thread{
public int x = 0;
public void run(){
System.out.println(++x);
}
}
class R implements Runnable{ ......
¹Ø¼ü×Ö: json java
JSON-libÕâ¸öJavaÀà°üÓÃÓÚ°Ñbean,mapºÍXMLת»»³ÉJSON²¢Äܹ»°ÑJSONת»Ø³ÉbeanºÍDynaBean¡£
ÏÂÔØµØÖ·:http://json-lib.sourceforge.net/
»¹ÒªÐèÒªµÄµÚ3·½°ü:
org.apache.commons(3.2ÒÔÉϰ汾)
org.apache.oro
net.sf.ezmorph(ezmorph-1.0.4.jar)
nu.xom
1¡¢List
Java´úÂë
boolean[] bool ......
1.factoryÒòΪ¹¤³§Ä£Ê½¾ÍÏ൱ÓÚ´´½¨ÊµÀý¶ÔÏóµÄnew£¬ÎÒÃǾ³£Òª¸ù¾ÝÀàClassÉú³ÉʵÀý¶ÔÏó£¬
ÈçA a=new A() ¹¤³§Ä£Ê½Ò²ÊÇÓÃÀ´´´½¨ÊµÀý¶ÔÏóµÄ£¬ËùÒÔÒÔºónewʱ¾ÍÒª¶à¸öÐÄÑÛ£¬ÊÇ·ñ¿ÉÒÔ¿¼ÂÇʵÓù¤³§Ä£Ê½£¬
ËäÈ»ÕâÑù×ö£¬¿ÉÄܶà×öһЩ¹¤×÷£¬µ«»á¸øÄãϵͳ´øÀ´¸ü´óµÄ¿ÉÀ©Õ¹ÐԺ;¡Á¿ÉÙµÄÐÞ¸ÄÁ¿¡£
2.PrototypeģʽÔÊÐíÒ»¸ö¶ÔÏóÔÙ´´½¨Á ......
1. ¿ª·¢¹¤¾ß £º MyEclipse5.5, FlexBuilder3, Tomcat6.
2. ¿ª·¢¹ý³Ì £º
µÚÒ»²½ £º ÏÂÔØBlazeDS, µØÖ·£ºhttp://opensource.adobe.com/wiki/display/blazeds/Release+Builds, ½âѹËõ¡£
µÚ¶þ²½ £º ÔÚMyEclipseÖÐн¨WEB¹¤³Ì£¬µ¼ÈëÒÀÀµ¿â£º
  ......
ÕâÀïÖ»ÄÜ´ÓÏÔʾÊý¾ÝµÄjspÒ³ÃæÉϵ¼³öµ±Ç°Ò³ÃæµÄÊý¾Ý£¬ÕâЩÊý¾Ý¿ÉÒÔ´ÓÊý¾Ý¿â¶Á³ö£¬ÏÔʾµ½jspÒ³Ãæ£¬È»ºó¼ÓÒ»¶Î»°¾Í¿É°Ñµ±Ç°Ò³ÃæÊý¾Ý±£´æµ½excelÀïÃæ!
Èç´Óºǫ́¹ýÀ´Êý¾ÝÏÔʾµ½ showUser.jsp
È»ºó¼ÓÁ´½Óµ½ showExcel.jsp¾Í¿ÉÒÔÁË£¬ÔÚÕâ¸öÒ³ÃæÖ»¶àÁ˼¸ÐÐ×Ö£¬ÆäËûµÄ¶¼²»»áÏÔʾ°üÀ¨Ò³Ã棡µ«Õâ¸öÒ³ÃæÉϵÄÊý¾Ý¸úshowUser.js ......