Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java and XML_¶ÁÊé±Ê¼Ç_2010 05 16

2010-05-16
Èý¡¢½âÎöXMLÎĵµ
l  Xerces½âÎöÆ÷¡¢SAXÀàºÍ½Ó¿Ú
l  SAXÔĶÁÆ÷
n  Ê×ÏÈÒªµÃµ½Ò»¸ö·ûºÏSAX org.xml.sax.XMLReader½Ó¿Ú¹æ·¶µÄÀý×Ó£¬Õâ¸ö½Ó¿Ú¶¨ÒåÁ˽âÎöÐÐΪ²¢ÔÊÐíÉèÖÃijЩÌØÕ÷ºÍÊôÐÔ¡£¸Ã½Ó¿ÚÌæ»»ÁËSAX1.0ÖеÄorg.xml.sax.Parser
import org.apache.xerces.parsers.SAXParser;
import org.xml.sax.XMLReader;
XMLReader parser = new SAXParser();
parser.parse(uri);
n  µ±Ò»¸ö½âÎöÆ÷µ÷Èë²¢×¼±¸¾ÍÐ÷ºó£¬Ëü¾Í¿ÉÒÔ¶ÔÎĵµ½øÐнâÎöÁË£¬Í¨³£ÓÉparse()·½·¨µÄorg.xml.sax.XMLReaderÀ´´¦ÀíÒ»¸öorg.xml.sax.InputSource»òÕßÒ»¸öURI´®¡£
n  ÄÚÈݹÜÀíÆ÷£ºÔÚ½âÎö½øÐÐʱ£¬ÎªÊ¹Ó¦ÓóÌÐòÓÐЧµØ´¦ÀíXMLÊý¾Ý£¬±ØÐëÓÃSAX½âÎöÆ÷µÇ¼Ç¹ÜÀíÆ÷£¨handler£©¡£¹ÜÀíÆ÷ÊÇÒ»×éSAX¶¨ÒåµÄ»Øµ÷£¬ËüÄÜÔÚÎĵµ½âÎö¹ý³ÌÖиøÖØÒªµÄʼþ²åÈëÏàÓ¦µÄÓ¦ÓóÌÐò´úÂë¡£ÕâЩʼþÓëÎĵµ½âÎöͬʱ½øÐС£SAX³ÉΪһ¸öÇ¿´ó½Ó¿ÚµÄÔ­ÒòÖ®Ò»£º²»ÐèÒªÔÚÆðʼʱ¾Í½«È«²¿Îĵµ¶ÁÈëÄڴ棬¶þÊ®¿ÉÒÔ¶ÔÆä½øÐÐÁ¬Ðø´¦Àí¡£
n  SAX2.0¶¨ÒåÁËËĸöºËÐĵĹÜÀíÆ÷½Ó¿Ú£ºorg.xml.sax.ContentHandler¡¢org.xml.sax.ErrorHandler¡¢org.xml.sax.DTDHandler¡¢org.xml.sax.EntityResolver¡£½âÎö¹ý³ÌÖУ¬Ö´ÐÐÌض¨¶¯×÷µÄ¶¨ÖÆÓ¦ÓÃÀàÖ§³ÖËùÓнӿڣ¬ÕâЩִÐÐÀà¿ÉÒÔÓÃSetContentHandler()¡¢setDTDHandler()ºÍsetEntityResolver()µÄ·½·¨ÔÚ½âÎöÆ÷ÉÏ×¢²á¡£
u  Îĵµ¶¨Î»Æ÷£ºorg.xml.sax.Locatorµ±Ä³»Øµ÷ʼþ³öÏÖʱ£¬Íê³É´¦ÀíµÄÀà±ØÐë´ÓSAX½âÎöÆ÷µÄXMLÎĵµÖÐÕÒµ½ÏàÓ¦µÄλÖá£
u  ÎĵµµÄ¿ªÍ·ºÍ½áβ£ºstartDocument()ºÍendDocument()
startDocument()ÔÚÈκÎÆäËû»Øµ÷֮ǰ±»µ÷ÓÃ
endDocument()¾­³£ÊÇÔÚËùÓйÜÀíÆ÷ÖÐ×îºó±»µ÷Óõķţ¬Èô²»¿É»Ö¸´ÐÔ´íÎó·¢Éú£¬ÔòErrorHandler»Øµ÷·½·¨½«±»»½ÐÑ£¬Í¬Ê±È¥µ÷ÓÃendDocument()½áÊø´Ë½âÎö¹ý³Ì¡£
ÕâÁ½¸ö»Øµ÷·½·¨¶¼»áÅ׳öSAXException£¬ÕâÒ²ÊÇSAXʼþ»áÅ׳öÒì³£µÄΨһ·½Ê½
u  ´¦ÀíÖ¸ÁSAX¶¨ÒåÁËÌØÊâµÄ»Øµ÷À´´¦ÀíÖ¸Áî¡£ÕâÖз½·¨½ÓÊÜ´¦ÀíÖ¸ÁîµÄÄ¿±êºÍÄÇЩ´«µÝ¸ø´¦ÀíÖ¸ÁîµÄËùÓÐÊý¾Ý¡£
u  Ãû×Ö¿Õ¼äµÄ»Øµ÷£ºÓÐÁ½ÖÖSAX»Øµ÷º¯ÊýרÃÅÓÃÓÚ´¦ÀíÃû×ֿռ䣨¾¡¹ÜÔªËػص÷ҲʹÓÃËüÃÇ£©¡£µ±½âÎöÆ÷µ½µ×ǰ׺ӳÏñ£¨prefix mapping£©µÄ¿ªÍ·ºÍ½áβʱ£¬ËüÃDZ»»½ÐÑ
startPrefixMapping()»Øµ÷¸ø³öÓëURIÏà¹ØµÄÃû×Ö¿Õ¼äǰ׺¡£Ç°×ºÓ³Ïñ»Øµ÷ÔÚÉùÃ÷Ãû×Ö¿Õ¼äµÄÔªËػص÷֮ǰÁ¢¼´·¢Éú¡£
endPrefixMapping()»Øµ÷ÔÚÉùÃ÷Ó³ÏñµÄÔªËصĽáÊø±êÇ©Ö®ºóÁ¢¼´³öÏÖ
u  Ô


Ïà¹ØÎĵµ£º

java£ºµÝ¹é£ºÉÏÂ¥ÌÝÿ´ÎÖ»ÄÜÒ»²½»òÕßÁ½²½£¬ÓжàÉÙ×ß·¨

package floatt;
public class Go {
 public static int i = 0;
 public static void main(String[] args){
  calc("", 5);
  System.out.println("×ܹ²ÓÐ"+i+"ÖÖ×ß·¨~");
 }
 
 //ÉÏÂ¥ÌÝÿ´ÎÖ»ÐèÒ»²½»òÕßÁ½²½£¬ÓжàÉÙ×ß·¨
 public static void calc(String lo ......

java£ºµÝ¹é£ºººÂÞËþÓÎÏ·¼ÆËã³ö×îÉٵIJ½Êý

package game;
public class HanTa {
 public static int i = 0;
 public static void main(String[] args){
  calc('A', 'B', 'C', 2);
  System.out.println("×îÉÙÐèÒª"+i+"²½¡£");
 }
 
 //ººÂÞËþÓÎÏ·¼ÆËã
 public static void calc(char src, char ilde, c ......

java£ºµÝ¹é£º10ԪǮ°´1£¬2£¬5ÔªÈÎÒâ×éºÏ

package game;
public class Money {
 public static void main(String[] args) {
  fun("", 10);
  System.out.println("×ܹ²Ëã·¨£º" + i);
 }
 // 10ԪǮµÄ×é³É£¬1£¬2£¬5ÈÎÒâ×éºÏ
 public static int i = 1;
 public static void fun(String log, int n) {
  ......

Java ÈÕÖ¾

19.1.1. Spring¶Ôlog4jµÄ¼¸¸öÔöÇ¿
×¢Òâ
¸öÈ˽¨Ò鶼²»ÒªÊ¹Óá£
¶¨Ê±Ë¢ÐÂlog4j.properties£¬ÎÞÐëÖØÆô·þÎñÆ÷¸üÐÂlog4jÉèÖá£ËäÈ»ÕâÊǸöJ2EE Best
Practice£¬µ«ÔÚSpringµÄJavaDocÀï×¢Ã÷Á˲»ÍƼöÓÃÓÚÉú²ú»·¾³£¬ÒòΪ·þÎñÆ÷ÖØÆôµÄʱºò£¬ÄÇÌõwatch thread²»»á¹Ø±Õ¡£
½«
log4j.propertiesÎļþ·ÅÔÚWEB-INF/log4j.properti ......

Java ϵͳÊôÐÔ System.getProperty


System.getProperty(String name)·½·¨ÓÃÓڵõ½ÏµÍ³µÄÊôÐÔ.SystemÊÇÔÚlang°üÖеÄÒ»¸öÀ࣬Õâ¸öÀàÖдæÔÚ´óÁ¿ºÍϵͳ´ò½»µÀµÄʵÓ÷½·¨£¬¶øÇÒÒ»°ã¶¼ÊÇÀà·½
·¨£¬.getProperty(String   key)¾ÍÊÇÆäÖÐÒ»¸ö±È½Ï³£Óõķ½·¨£¬ÓÃÓÚ·µ»Øϵͳ²ÎÊýÎļþÖÐÕâ¸ö·½·¨Ö¸¶¨¼üËù´ú±íµÄÖµ¡£
ÏÂÃæÊǸ÷½·¨µÄ³£ÓòÎÊý¡£¹Ø¼üÒâÒå ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ