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

ʹÓÃJava·¢ËÍPOST¡¢GETÇëÇó

 Ê¹ÓÃJava·¢ËÍGET¡¢POSTÇëÇó
——½ÚÑ¡×Ô¡¶·è¿ñJava½²Òå¡·
URLµÄopenConnection()·½·¨½«·µ»ØÒ»¸öURLConnection¶ÔÏ󣬸öÔÏó±íʾӦÓóÌÐòºÍ URL Ö®¼äµÄͨÐÅÁ´½Ó¡£³ÌÐò¿ÉÒÔͨ¹ýURLConnectionʵÀýÏò¸ÃURL·¢ËÍÇëÇ󡢶ÁÈ¡URLÒýÓõÄ×ÊÔ´¡£
ͨ³£´´½¨Ò»¸öºÍ URL µÄÁ¬½Ó£¬²¢·¢ËÍÇëÇ󡢶ÁÈ¡´Ë URL ÒýÓõÄ×ÊÔ´ÐèÒªÈçϼ¸¸ö²½Ö裺
£¨1£©Í¨¹ýµ÷ÓÃURL¶ÔÏóopenConnection()·½·¨À´´´½¨URLConnection¶ÔÏó¡£
£¨2£©ÉèÖÃURLConnectionµÄ²ÎÊýºÍÆÕͨÇëÇóÊôÐÔ¡£
£¨3£©Èç¹ûÖ»ÊÇ·¢ËÍGET·½Ê½ÇëÇó£¬Ê¹ÓÃconnect·½·¨½¨Á¢ºÍÔ¶³Ì×ÊÔ´Ö®¼äµÄʵ¼ÊÁ¬½Ó¼´¿É£»Èç¹ûÐèÒª·¢ËÍPOST·½Ê½µÄÇëÇó£¬ÐèÒª»ñÈ¡URLConnectionʵÀý¶ÔÓ¦µÄÊä³öÁ÷À´·¢ËÍÇëÇó²ÎÊý¡£
£¨4£©Ô¶³Ì×ÊÔ´±äΪ¿ÉÓ㬳ÌÐò¿ÉÒÔ·ÃÎÊÔ¶³Ì×ÊÔ´µÄÍ·×ֶΡ¢»òͨ¹ýÊäÈëÁ÷¶ÁÈ¡Ô¶³Ì×ÊÔ´µÄÊý¾Ý¡£
ÔÚ½¨Á¢ºÍÔ¶³Ì×ÊÔ´µÄʵ¼ÊÁ¬½Ó֮ǰ£¬³ÌÐò¿ÉÒÔͨ¹ýÈçÏ·½·¨À´ÉèÖÃÇëÇóÍ·×ֶΣº
setAllowUserInteraction£ºÉèÖøÃURLConnectionµÄallowUserInteractionÇëÇóÍ·×ֶεÄÖµ¡£
setDoInput£ºÉèÖøÃURLConnectionµÄdoInputÇëÇóÍ·×ֶεÄÖµ¡£
setDoOutput£ºÉèÖøÃURLConnectionµÄdoOutputÇëÇóÍ·×ֶεÄÖµ¡£
setIfModifiedSince£ºÉèÖøÃURLConnectionµÄifModifiedSinceÇëÇóÍ·×ֶεÄÖµ¡£
setUseCaches£ºÉèÖøÃURLConnectionµÄuseCachesÇëÇóÍ·×ֶεÄÖµ¡£
³ý´ËÖ®Í⣬»¹¿ÉÒÔʹÓÃÈçÏ·½·¨À´ÉèÖᢻòÔö¼ÓͨÓÃÍ·×ֶΣº
setRequestProperty(String key, String value)£ºÉèÖøÃURLConnectionµÄkeyÇëÇóÍ·×ֶεÄֵΪvalue¡£ÈçÏ´úÂëËùʾ£º
conn.setRequestProperty("accept" , "*/*")
addRequestProperty(String key, String value)£ºÎª¸ÃURLConnectionµÄkeyÇëÇóÍ·×ֶεÄÔö¼ÓvalueÖµ£¬¸Ã·½·¨²¢²»»á¸²¸ÇÔ­ÇëÇóÍ·×ֶεÄÖµ£¬¶øÊǽ«ÐÂÖµ×·¼Óµ½Ô­ÇëÇóÍ·×Ö¶ÎÖС£
µ±Ô¶³Ì×ÊÔ´¿ÉÓÃÖ®ºó£¬³ÌÐò¿ÉÒÔʹÓÃÒÔÏ·½·¨ÓÃÓÚ·ÃÎÊÍ·×ֶκÍÄÚÈÝ£º
Object getContent()£º»ñÈ¡¸ÃURLConnectionµÄÄÚÈÝ¡£
String getHeaderField(String name)£º»ñÈ¡Ö¸¶¨ÏìӦͷ×ֶεÄÖµ¡£
getInputStream()£º·µ»Ø¸ÃURLConnection¶ÔÓ¦µÄÊäÈëÁ÷£¬ÓÃÓÚ»ñÈ¡URLConnectionÏìÓ¦µÄÄÚÈÝ¡£
getOutputStream()£º·µ»Ø¸ÃURLConnection¶ÔÓ¦µÄÊä³öÁ÷£¬ÓÃÓÚÏòURLConnection·¢ËÍÇëÇó²ÎÊý¡£
×¢Ò⣺Èç¹û¼ÈҪʹÓÃÊäÈëÁ÷¶ÁÈ¡URLConnectionÏìÓ¦µÄÄÚÈÝ£¬Ò²ÒªÊ¹ÓÃÊä³öÁ÷·¢ËÍÇëÇó²ÎÊý£¬Ò»¶¨ÒªÏÈʹÓÃÊä³öÁ÷£¬ÔÙʹÓÃÊäÈëÁ÷¡£
getHeaderField·½·¨ÓÃÓÚ¸ù¾ÝÏìӦͷ×Ö¶ÎÀ´·µ»Ø¶ÔÓ¦µÄÖµ¡£¶øijЩͷ×Ö¶ÎÓÉÓÚ¾­³£ÐèÒª·ÃÎÊ


Ïà¹ØÎĵµ£º

JAVAÐÂÊÖÆð²½

        Èç¹û´Ó·­¿´Thinking in java ÕâÊéËãÆð£¬ÄÇÎÒÒѾ­¿´Á˲¶àÈý¸öÔÂÁË£¬µ«ÊÇÊÂʵÉÏÕæÕý°Ñ»¨ÔÚ˼¿¼JAVAÎÊÌâÉϵÄʱ¼äËãÏ£¬¿ÉÕæÊÇÈÃ×Ô¼º¶¼Óеã˵²»¹ýÈ¥¡£ÖÖÖÖÀíÓɶ¼³ä³â×ÅÎÒµÄÉñ¾­£¬µ«Î޷Ƕ¼ÊÇÀÁ¶èÕßµÄ×ÔÎÒ±£»¤µÄÊֶΣ¬ÎÒ²»µÃ²»¸Ð¿®ÕæµÄÊÇ×Ô¼ºÌ«²»ÉϽøÁË¡£
   &nbs ......

java²¢·¢±à³Ìʵ¼ù±Ê¼Ç

  1, ±£Ö¤Ḭ̈߳²È«µÄÈýÖÖ·½·¨: a, ²»Òª¿çÏ̷߳ÃÎʹ²Ïí±äÁ¿b, ʹ¹²Ïí±äÁ¿ÊÇfinalÀàÐ͵Äc, ½«¹²Ïí±äÁ¿µÄ²Ù×÷¼ÓÉÏͬ²½
    2, Ò»¿ªÊ¼¾Í½«ÀàÉè¼Æ³ÉḬ̈߳²È«µÄ, ±ÈÔÚºóÆÚÖØÐÂÐÞ¸´Ëü,¸üÈÝÒ×.
    3, ±àд¶àÏ̳߳ÌÐò, Ê×Ïȱ£Ö¤ËüÊÇÕýÈ·µÄ, Æä´ÎÔÙ¿¼ÂÇÐÔÄÜ.
    4, ÎÞ ......

javaÓÎÏ·Ö÷ÒªµÄ¼¼Êõ

1£¬Java3D ×÷Ϊsun¹«Ë¾½ÏÔçÍƳöµÄÒ»Ïî3d¼¼Êõ£¬ÊÇÒ»Öָ߶ȷâ×°µÄapi£¬¹¹½¨ÔÚopenglºÍdirect3dÖ®ÉÏ£¬¿ÉÒÔ˵ÊÇ×îÓÐÃûµÄjavaµÄ3d¼¼Êõ¡£ÓÉÓÚÖÖÖÖÔ­Òò£¨apiÉè¼Æ£¬ÃæÏòµÄÓû§²»Ã÷È·£©£¬java3dһֱûÓа취Á÷ÐУ¬²»¾ÃÇ°java3dµÄÍŶÓÐû²¼ÔÝÍ£¶Ôjava3dй¦ÄܵĿª·¢£¬×ª¶øΪJavaFX¿ª·¢3d äÖȾÒýÇ档ͬʱsunµÄÁíÒ»¸öÏîÄ¿ project wonder ......

javaÖÐÊäÈëÊä³ö×ܽá

µÚÒ»½Ú Êý¾ÝÁ÷µÄ»ù±¾¸ÅÄî
      Àí½âÊý¾ÝÁ÷
Á÷Ò»°ã·ÖΪÊäÈëÁ÷£¨Input Stream£©ºÍÊä³öÁ÷£¨Output Stream£©Á½À࣬µ«ÕâÖÖ»®·Ö²¢²»ÊǾø¶ÔµÄ¡£±ÈÈçÒ»¸öÎļþ£¬µ±ÏòÆäÖÐдÊý¾Ýʱ£¬Ëü¾ÍÊÇÒ»¸öÊä³öÁ÷£»µ±´ÓÆäÖжÁÈ¡Êý¾Ýʱ£¬Ëü¾ÍÊÇÒ»¸öÊäÈëÁ÷¡£µ±È»£¬¼üÅÌÖ»ÊÇÒ»¸öÊýÈËÁ÷£¬¶øÆÁÄ»ÔòÖ»ÊÇÒ»¸öÊä³öÁ÷¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ