¼¸ÖÖ¶ÁÈ¡ÊôÐÔÎļþµÄJAVAʵÏÖ·½Ê½
1.ʹÓÃjava.util.PropertiesÀàµÄload()·½·¨
¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = lnew BufferedInputStream(new FileInputStream(name));
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
InputStream in = lnew BufferedInputStream(new FileInputStream(name));
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
¡¡¡¡
¡¡¡¡2.ʹÓÃjava.util.ResourceBundleÀàµÄgetBundle()·½·¨¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault());
ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault());
¡¡¡¡
¡¡¡¡3.ʹÓÃjava.util.PropertyResourceBundleÀàµÄ¹¹Ô캯Êý¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = new BufferedInputStream(new FileInputStream(name));
¡¡¡¡ResourceBundle rb = new PropertyResourceBundle(in);
InputStream in = new BufferedInputStream(new FileInputStream(name));
¡¡¡¡ResourceBundle rb = new PropertyResourceBundle(in);
¡¡¡¡
¡¡¡¡4.ʹÓÃclass±äÁ¿µÄgetResourceAsStream()·½·¨¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = JProperties.class.getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
InputStream in = JProperties.class.getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
¡¡¡¡
¡¡¡¡5.ʹÓÃclass.getClassLoader()ËùµÃµ½µÄjava.lang.ClassLoaderµÄgetResourceAsStream()·½·¨¡¡¡¡
¡¡¡¡Ê¾Àý£º
Java´úÂë
InputStream in = JProperties.class.getClassLoader().getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
InputStream in = JProperties.class.getClassLoader().getResourceAsStream(name);
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
¡¡¡¡
¡¡¡¡6.ʹÓÃjava.lang.ClassLoad
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
1.ÓÃnew String(request.getParameter("name").getBytes("ISO-8859-1"),"GBK") ·½Ê½½øÐÐתÂë
2.ÉèÖÃtomcat£ºÔÚtomcatµÄconfĿ¼ÏÂÕÒµ½server.xmlÎļþ£¬ÔÚConnector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
......
ÖÐÎÄÂÒÂë½â¾ö·½°¸£º
Êý¾Ý¿âÂÒÂë:
UTF-8¶ÔÖÐÎÄÓÃ3¸ö×Ö½ÚÀ´±íʾ
String s =”·ÉÏè”;
byte[] utf8 = s.getBytes(“utf-8”);//»ñµÃutf-8±àÂëµÄ×Ö½ÚÖµ
System….(new String(utf8,”gbk”);//ÓÃGBK±àÂë¸ñʽ¶ÔUTF-8±àÂë¸ñʽµÄ×Ö½ÚÊý×é½øÐнâÂ룬½«²úÉúÂÒÂë¡£
²é¿´Êý¾Ý¿âµÄ× ......
JavaÄÚ²¿À൱³õµÄÉè¼ÆÄ¿µÄÓ¦¸ÃÊÇʵÏÖ¶àÖؼ̳У¬ºóÀ´·¢ÏÖÄÚ²¿À໹´øÀ´ÁËÆäËûºÃ´¦£¬Èç¿ÉÒÔʹÓÃÄÚ²¿Àà°üװһЩº¯Êý£¬ÊµÏÖº¯Êý¼¶±ðµÄȨÏÞ¿ØÖƵȡ£
JavaÖУ¬LIst.subList()µÈ·½·¨²úÉúµÄÊÇÒ»¸öview£¬¼´²»ÊÇ´«Öµ£¬¶ø½öÊÇÒýÓá£ËƺõÔÚjavaÖгýÁËprimitiveÀ࣬ÆäËûÀ඼Ðènew²ÅÄܲúÉúжÔÏó¡£
iBatis DAO¿ò¼ÜÍ ......