Ààajax jsp ÎÞË¢ÐÂÉÏ´«Îļþ
Ê×ÏÈҪ˵µÄ¾ÍÊÇ ajax ÊÇÎÞ·¨ÊµÏÖÉÏ´«ÎļþµÄ£¬¿ÉÒÔÏëÒ»ÏÂajaxÓëºǫ́ͨÐŶ¼ÊÇͨ¹ý´«µÝ×Ö·û´®£¬ÔõôÄÜ´«µÝÎļþÄØ£¿Æäʵ³öÓÚ°²È«¿¼ÂÇjsÊDz»ÄܲÙ×÷ÎļþµÄ£¬ËùÒԾͲ»ÒªÔÙ˵ÓÃajaxÀ´ÊµÏÖÎļþµÄÉÏ´«ÁË£¬ÕâÊDz»¿ÉÄܵġ£
¶ø±¾ÎÄʵÏÖµÄÎļþÉÏ´«Ò²ÊÇÎÞÒ³Ãæˢеģ¬¿ÉÒÔ˵ÊÇÒ»ÖÖ"ÀàËÆAJAX"·½·¨¡£
¿ªÊ¼Ö®Ç°ÏÈ˵Á½¾äÎ޹صģ¬ÆäʵÔÚajax³öÏÖ֮ǰ£¬webÓ¦ÓÃÒ²¿ÉÒÔÊÇÎÞˢеģ¬ÄÇʱ´ó¶àͨ¹ýIFrameÀ´×öµ½ÕâÒ»µã¡£µ±È»Ajax³öÏÖÖ®ºó£¬ÈËÃÇÒ»ÎÑ·äµØͶ±¼Ajax µÄÕóÓªÁË£¬iFrame ¾Í·¦ÈËÎʽòÁË¡£µ«ÊÇÓÃiFrameÀ´ÊµÏÖÎÞË¢ÐÂÉÏ´«Îļþȷʵһ¸öºÜºÃµÄÑ¡Ôñ¡£ps£ºAjax¼¼Êõ»ù±¾ÉÏ¿ÉÒÔ˵ÊÇÓÉgoogle¹«Ë¾´øÆðÀ´µÄ£¬µ«ÉÙGmailÖÐÉÏ´«ÎļþÓõĻ¹ÊÇ IFrame£¬ËùÒÔ˵ʹÓÃIFrameÀ´ÉÏ´«ÎļþÊÇ×îºÃµÄÑ¡Ôñ¡£
ÎÒÔÚÕâÀïÕâÀïÓõļ¼ÊõÊÇjsp£¬Æäʵasp£¬phpµÈÒ²ÊÇÒ»Ñù¿ÉÒÔÕâôʵÏÖµÄ
Ò»¹²Á½¸öÎļþ¾Í¿ÉʵÏÖ£ºindex.html ºÍ upload.jsp£¬ÔÚÕâÀï½²½âһϣ¬Îĺó»á¸½ÉÏÔ´Âë
--index.html
html ´úÂë
£¼html£¾
£¼body£¾
£¼form action="upload.jsp" id="form1" name="form1" encType="multipart/form-data" method="post" target="hidden_frame" £¾
£¼input type="file" id="file" name="file" style="width:450"£¾
£¼INPUT type="submit" value="ÉÏ´«Îļþ"£¾£¼span id="msg"£¾£¼/span£¾
£¼br£¾
£¼font color="red"£¾Ö§³ÖJPG,JPEG,GIF,BMP,SWF,RMVB,RM,AVIÎļþµÄÉÏ´«£¼/font£¾
£¼iframe name='hidden_frame' id="hidden_frame" style='display:none'£¾£¼/iframe£¾
£¼/form£¾
£¼/body£¾
£¼/html£¾
£¼script type="text/javascript"£¾
function callback(msg)
{
document.getElementById("file").outerHTML = document.getElementById("file").outerHTML;
document.getElementById("msg").innerHTML = "£¼font color=red£¾"+msg+"£¼/font£¾";
}
£¼/script£¾
index.html ÖÐÖ÷ÒªÒª×öµÄ¾ÍÊÇдһ¸ö form ºÍ iframe £¬²¢°Ñ form µÄ target ÉèΪ iframe µÄÃû×Ö£¬×¢ÒâÒª°Ñ iframe ÉèΪ²»¿É¼û£¬ÆäËûµÄ¶¼ÊÇÕý³£µÄÎļþÉÏ´«µÄд·¨£¬ÕâÑùˢеÄÒ³Ãæ¾ÍÊÇÕâ¸öÒþ²ØµÄ Iframe £¬¶øÔÚ index.html ÖÐÊDz»»áÓÐÒ³Ãæˢеģ¬jsµÄ callback ·½·¨Êǻص÷·½·¨¡£ÓÃÓÚÇå¿ÕÎļþ
Ïà¹ØÎĵµ£º
ÔÚÏîÄ¿ÖУ¬ÎÒÃǾ³£Óöµ½ÐèÒªÔÚjspÒ³ÃæÇл»Öд«µÝÖÐÎÄ×Ö·û¡£ÕâÖ÷ÒªÓÐÁ½ÖÖ·½Ê½¡£
¡¡¡¡URL·½Ê½£¬ÀýÈ磺http://website/test1.jsp?act=add&type=Æ»¹û¶m=%20D%20B
¡¡¡¡FORM·½Ê½£¬ÀýÈ磺
¡¡¡¡<form name=test mehtod="post">
¡¡¡¡<input type=hidden name=text2 value="ÖÐÎÄ">
¡¡¡¡<input type=t ......
By Jason.Huang@sun.COM
,
8/1/07
B/S½á¹¹µÄÓ¦ÓÃËƺõÒѾ³ÉΪÁËĬÈϵķ½Ê½,´ó¼ÒÿÌ쿪Æô¹Ø±Õ×î¶àµÄÓ¦ÓÃÎÒÏëÓ¦¸ÃÊÇÄúµÄWebä¯ÀÀÆ÷.B/S½á¹¹µÄÓ¦ÓÃ×î´óµÄÓŵã¾ÍÊÇ·½±ã,¿Í»§¶ËʲôҲ
²»ÐèÒª°²×°¾Í¿ÉÒÔʹÓÃÎÒÃǵÄÓ¦ÓÃ.
µ±È»B/S½á¹¹µÄһЩÌصãÒ²¶Ô»ùÓÚÕâÖÖ·½Ê½Ó¦ÓõĿª·¢ºÍÉè¼Æ²úÉúÁËÓ°Ïì.
×îµäÐ͵ÄÎÊÌâ¾ÍÊÇÿ ......
Ò»¡¢ н¨Ò»¸öAjax_StartµÄÍøÕ¾
¶þ¡¢ ÔÚÍøÕ¾ÖÐÌí¼ÓÒ»¸öweb·þÎñ£¨ws_start.asmx£©
ÔÚvs2008ÖУ¬Ìí¼ÓÒ»¸öweb·þÎñÉú³ÉÁËÁ½¸öÎļþ£¬Ò»¸öÊÇasmxÎļþ£¬Ò»¸öÊÇÔÚApp_codeÀïµÄcsÎļþ£»ÎÒ¾õµÃÕâÑù²¢²»ºÃ£¬Ö ......
Tomcat½«jsp±àÒë³ÉservletºóµÄÎļþ´æ·ÅÔÚ\work\CatalinaĿ¼Ï£¬ÀýÈçjspÎļþ\webapps\hh\h.jsp£¬±àÒëºó
\work\Catalina\localhost\hh\org\apache\jsp\h_jsp.java
servletÎļþºÍ.classÎļþ¶¼ÔÚͬһĿ¼Ï¡£
¿ØÖÆ̨±¨µÄÒì³£ÐÐÊýÊÇÖ¸±àÒë¹ýºóµÄservletÎļþ,¶ø²»ÊÇÄãÔÀ´µÄjspÎļþ£¡ ......
Ç°ºó¶ËµÄ½»»¥ÊÇÕû¸ö¿ò¼ÜµÄÖÐÐÄ£¬ÎÒÏ£Íû´ÓÁ÷µÄ½Ç¶ÈÀ´Éè¼ÆAJAXµÄ½»»¥
AJAXµÄÉè¼Æ½«ºá¹áÇ°ºó¶Ë
Ç°¶ËÊÇÖ÷¶¯
ºó¶ËÊDZ»¶¯
ÕûÌ忼ÂǵĻ° Ç°ºó¶ËʹÓÃÒ»¸öͳһµÄ½Ó¿Ú½øÐÐAJAX½»»¥
ºó¶Ë ÓÃÒ»¸öΨһµÄURLÀ´´¦Àí AJAXÇëÇó
½Ó¿ÚÃû³Æ ´¦Àí½Ó¿Ú£º[http://ÓòÃû/mvc.ajax] ·â×°ËùÓеÄAJAXÇëÇóµÄÔ¤´¦Àí
......