java½âÎöxml
Ìâ¼Æ£ºÕâÀï¸ø³öjava½âÎöxml£¬ÒÔ°ïÖúÈËÃÇÀí½âÐí¶àÈÝÆ÷ÊÇÔõô×öµÄ¡£¡£Ïñspring£¬strutsµÈ.
1.mysql.xml´úÂ룺
<?xml version="1.0" encoding="UTF-8"?>
<data>
<datasource>
<servername>localhost</servername>
<serverport>3306</serverport>
<databasename>juddi</databasename>
<username>root</username>
<password>123456</password>
</datasource>
</data>
2.XMLÅäÖÃÎļþ½âÎöÆ÷,Ö÷ҪĿµÄ£¬ÊÇΪ×öÇ°ÆÚ¹¤×÷
package com;
/*
* XMLÅäÖÃÎļþ½âÎöÆ÷,Ö÷ҪĿµÄ£¬ÊÇΪ×öÇ°ÆÚ¹¤×÷
*/
import org.xml.sax.helpers.DefaultHandler;
import java.util.Properties;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
public class ConfigParser extends DefaultHandler {
//¶¨ÒåÒ»¸öpropertiesÓÃÀ´´æ·ÅÊôÐÔ
private Properties props;
private String currentName;
private StringBuffer currentValue=new StringBuffer();
public ConfigParser(){
this.props=new Properties();
}
public Properties getProps(){
return this.props;
}
//ÕâÀïÊǽ«xmlÖÐÔªËØÖµ¼ÓÈëcurrentValue
public void characters(char[] ch, int start, int length)
throws SAXException {
currentValue.append(ch, start, length);
}
//ÔÚÓöµ½</xx>ʱ£¬½«Ö®¼äµÄ×Ö·û´æ·ÅÔÚpropsÖмä
public void endElement(String uri, String localName, String name)
throws SAXException {
props.put(currentName.toLowerCase(), currentValue.toString().trim());
}
//¶¨Ò忪ʼ½âÎöÔªËصķ½·¨£¬ÕâÀォ<xx>ÖеÄÃû³ÆxxÌá³öÀ´£¬
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
currentValue.delete(0, currentValue.length());
currentName=qName;
}
//
}
3.XMLÅäÖÃÎļþ¼ÆÈ¡´¦Àí
package com;
/*
* XMLÅäÖÃÎļþ¼ÆÈ¡´¦Àí
*/
import java.util.Properties;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
public class ParseXML {
//¶¨ÒåÒ»¸öProertiesÓÃÀ´´æ·ÅÊôÐÔÖµ
private Properties props;
public Prope
Ïà¹ØÎĵµ£º
MyEclipseÉèÖÃJSPÒ³ÃæĬÈϱàÂ뷽ʽ£º
windows(´°¿Ú)-Preferences(Ê×Ñ¡Ïî)-MyEclipse-Files & Editors-JSP-ÓÒ²àencoding:ÉèÖÃΪISO10646/Unicode(UTF-8)
MyEclipseÔÚJavaÎļþÖÐÉèÖÃ×÷Õß¡¢ÈÕÆÚµÈ˵Ã÷£º
windows(´°¿Ú)-Preferences(Ê×Ñ¡Ïî)-Java-Code Style(´úÂëÑùʽ)-Code Templates(´úÂëÄ£°æ)-ÓÒ²àComments(×¢ÊÍ)- ......
³£ÓõÄÉè¼Æģʽ·ÖΪÈçÏ 23 ÖÖģʽ£º
Abstract Factory£º
Ìṩһ¸ö´´½¨Ò»ÏµÁÐÏà¹Ø»òÏ໥ÒÀÀµ¶ÔÏóµÄ½Ó¿Ú£¬¶øÎÞÐèÖ¸¶¨ËüÃǾßÌåµÄÀà¡£
Adapter£º
½«Ò»¸öÀàµÄ½Ó¿Úת»»³É¿Í»§Ï£ÍûµÄÁíÒ»¸ö½Ó¿Ú£¬Ê¹µÃÔÀ´ÓÉÓÚ½Ó¿Ú²»¼æÈݶø²»ÄÜÒ»Æð¹¤×÷µÄÄÇЩÀà¿ÉÒÔÒ»Æð¹¤×÷¡£
Bridge£º
½«³éÏ󲿷ÖÓëËüµÄʵÏÖ²¿·Ö·ÖÀ룬ʹ֮¿ÉÒÔ¶ÀÁ¢±ä»¯¡£
C ......
1.JavaÔÚÐéÄâ»úÉÏÔËÐÐ
JavaÔ´´úÂë²¢²»ÊDZ»±àÒë³ÉΪÆÕͨµÄ»úÆ÷´úÂë¡£¶øÊDZ»·Òë³ÉΪÐéÄâ»ú¿ÉÒÔÖ´ÐеĴúÂë¡£Ò»¸öJava½âÊÍÆ÷×îÖÕÖ´ÐÐÕâЩ´úÂë¡£ÕâÆäÖÐûÓÐÁ¬½ÓµÄ¹ý³Ì£»½âÊÍÔÚÐèÒªµÄʱºò¶¯Ì¬µÄ¼ÓÔØһЩÀࣻ
2.JavaÊÇÍêÈ«ÃæÏò¶ÔÏóµÄ
JavaÊÇÒ»ÖÖÍêÈ«ÃæÏò¶ÔÏóµÄÓïÑÔ¡£ÕâÒâζ×ÅÄã¶ÔÈκÎÒ»¸öJava¶ÔÏóËù×öµÄ¶¯×÷¶¼ÊÇͨ¹ýÒ ......
תÔØ×Ô http://www.cn-java.com/www1/?action-viewnews-itemid-8283
ÓÉÓÚͬһ½ø³ÌµÄ¶à¸öÏ̹߳²ÏíͬһƬ´æ´¢¿Õ¼ä£¬ÔÚ´øÀ´·½±ãµÄͬʱ£¬Ò²´øÀ´ÁË·ÃÎʳåÍ»Õâ¸öÑÏÖصÄÎÊÌâ¡£JavaÓïÑÔÌṩÁËרÃÅ»úÖÆÒÔ½â¾öÕâÖÖ³åÍ»£¬ÓÐЧ±ÜÃâÁËͬһ¸öÊý¾Ý¶ÔÏ󱻶à¸öÏß³Ìͬʱ·ÃÎÊ¡£
¡¡¡¡ÐèÒªÃ÷È·µÄ¼¸¸öÎÊÌ⣺
¡¡¡¡1)synchronized¹Ø¼ü×Ö¿ÉÒÔ×÷Ϊ ......
´úÂë¿é£º¾ÍÊÇÓÃ{}À¨ÆðÀ´µ½²¿·Ö¡£¸ù¾ÝÓ¦ÓõIJ»Í¬·ÖΪ4Àà:ÆÕͨ´úÂë¿é¡¢¹¹Ôì¿é¡¢¾²Ì¬´úÂë¿é¡¢Í¬²½´úÂë¿é¡£
1.ÆÕͨ´úÂë¿é£º¶¨ÒåÔÚ·½·¨ÖеĴúÂë¿é¡£
È磺
public class Ex22 {
public static void main(String[] args){
// ÆÕͨ´úÂë¿é
{
int i = 3;
System.out.println("¾Ö²¿±äÁ¿Îª " + i);
}
int i = 5 ......