ÓÃGlassfishºÍNetBeans±àдµÚÒ»¸öAJAX³ÌÐò
By Jason.Huang@sun.COM
,
8/1/07
B/S½á¹¹µÄÓ¦ÓÃËƺõÒѾ³ÉΪÁËĬÈϵķ½Ê½,´ó¼ÒÿÌ쿪Æô¹Ø±Õ×î¶àµÄÓ¦ÓÃÎÒÏëÓ¦¸ÃÊÇÄúµÄWebä¯ÀÀÆ÷.B/S½á¹¹µÄÓ¦ÓÃ×î´óµÄÓŵã¾ÍÊÇ·½±ã,¿Í»§¶ËʲôҲ
²»ÐèÒª°²×°¾Í¿ÉÒÔʹÓÃÎÒÃǵÄÓ¦ÓÃ.
µ±È»B/S½á¹¹µÄһЩÌصãÒ²¶Ô»ùÓÚÕâÖÖ·½Ê½Ó¦ÓõĿª·¢ºÍÉè¼Æ²úÉúÁËÓ°Ïì.
×îµäÐ͵ÄÎÊÌâ¾ÍÊÇÿ´ÎºÍ·þÎñÆ÷µÄ½»»¥¶¼ÐèÒª·¢ÆðÒ»´ÎÇëÇó,´«Í³µÄ·½Ê½ÏÂÐèÒª°ÑÕû¸ö±íµ¥½øÐÐÌá½»,´¦ÀíÍê³ÉºóÐèÒª°Ñ±íµ¥ÔÙ´ÎÏÔʾ.
ÔÚʵ¼ÊÓ¦ÓÃÖÐ,ÎÒÃdz£³£ÐèÒª¶ÔWebÒ³ÃæµÄ¾Ö²¿×ö¶¯Ì¬´¦Àí,È»ºó×îºóÔÚ×öÕû¸ö±íµ¥µÄÌá½»´¦Àí.
ÀýÈç,ÔÚÌá½»×¢²áÐÅϢ֮ǰ,Ïȼì²é×¢²áÓû§ÃûÊÇ·ñ¿ÉÒÔʹÓÃ.
²»ÖªµÀÄãÊÇ·ñ²Î¼Ó2006ÄêÔÚ±±¾©¾ÙÐеÄSun Techday,ÔÚJames
GoslingÑݽ²Ö®ºóÀ´×ÔSun¹«Ë¾TE²¿Ãŵļ¼Êõ´«µÀÊ¿ÃÇ×öÁ˾«²ÊµÄ¼¼ÊõÑÝʾ,ÆäÖÐÒ»¸öÑÝʾÊǹØÓÚPetStore.
¾µäPetStoreÏÖÔÚÒѾ±äµÃÉú¶¯ÁËÐí¶à,ÆäÖÐÒ»¸öÖ÷ÒªµÄ¼¼Êõ¾ÍÊDzÉÓÃÁËAJAX.
AJAXʹµÃWebÓ¦Óñ£³ÖÁË"ÊÝ"¿Í»§¶Ë¼òµ¥µÄÓŵã,ͬʱҲÔö¼ÓÁË"ÅÖ"¿Í»§¶Ë²Ù×÷ÐԺõÄÓŵã.
AJAXÒѾ²»ÊÇÐÂÏÊÃû´ÊÁË,ÕâÀï¾Í²»×ö½éÉÜÁË,ÈÃÎÒÃÇÓÃÒ»¸ö¼òµ¥µÄÀý×ÓÀ´ÑÝʾÈçºÎ²ÉÓÃGlassfishºÍNetBeans±àдµÚÒ»¸öAJAX³ÌÐò.
Glassfish°²×°
ΪÁËÔËÐÐÕâ¸öÀý×Ó,ÄúÐèÒªÏÂÔز¢Æô¶¯Glassfish.
ÏÂÔØGalssfishµØÖ·£º
https://glassfish.dev.java.net/downloads/v1_ur1-p01-b02.html
°²×°·½·¨£º
java -Xmx256m -jar glassfish-installer-v1_ur1-p01-b02.jar
cd glassfish
ant -f setup.xml
˵Ã÷£ºÎªÁËÍê³É°²×°£¬ÄãÐèÒªÏÂÔØJDKºÍANT¡£
Æô¶¯·½·¨£º
cd glassfish
./bin/asadmin start-domain
Æô¶¯ºóÈçÏÂͼËùʾ£º
NetBeans °²×°
ͬʱΪÁËÌá¸ß¿ª·¢Ð§ÂÊ,ÍƼö´ó¼ÒʹÓÿªÔ´µÄIDE¹¤¾ß:
NetBeans,ʹÓÃNetBeans¿ÉÒÔºÍÖ÷Á÷µÄÓ¦Ó÷þÎñÆ÷Ïà½áºÏÍê³ÉJavaEE³ÌÐòµÄ¿ª·¢.
NetBeansµÄÏÂÔصØÖ·£º www.netbeans.org
ÏÂÃæÊÇÓÃNetBeasn¿ª·¢µÄÒ»¸öÓ¦ÓóÌÐòµÄÒ»¸ö½çÃ棺
AJAX³ÌÐò¿ª·¢
ËäÈ»AJAXÓ¦Óò»ÐèҪÿ´ÎÌá½»Õû¸öÒ³Ã棨»òÕßij¸öÒ³ÃæµÄiframe²¿·Ö£©£¬µ«ÊÇʵ¼ÊÉÏÔÚ¿ª·¢µÄʱºòÎÒÃÇ»¹ÊÇÒª½øÐÐ
¿Í»§ºÍ·þÎñÆ÷¶Ë³ÌÐòµÄͨѶ¡£Ö»²»¹ý£¬ºÍ´«Í³µÄ·½Ê½²»Í¬µÄÊÇ£¬j
ÎÒÃDz»ÔÙÊÇͨ¹ý±íµ¥(form)µÄ·½Ê½À´Ìá½»Êý¾Ý¸ø·þÎñÆ÷¶Ë£¬¶øÊÇͨ¹ýJava ScriptÔÚ»Ãæ±³ºó·¢³öÇëÇóºÍ´¦ÀíÏìÓ¦½á¹û²¢¸üÐÂä¯ÀÀÆ÷ÖеĻÃæ¡£
ÔÚ±¾ÎÄÖУ¬Í¨¹ýÒ»¸ö¼òµ¥³£ÓõÄCaseÀ´ËµÃ÷»ùÓÚGlassfishºÍNetBeansµÄAjax³ÌÐò¿ª·¢¹ý³Ì¡£ÔÚÕâ¸öCaseÖУ¬ÎÒÃÇʵÏÖÒ»¸ö
Óû§×¢²
Ïà¹ØÎĵµ£º
<script type="text/javascript">
function addUrl(){
//1¡¢ÉèÖÃÇëÇóurlµØÖ·
var name = document.getElementById("name").value;
var text = document.getElementById("url").value;
var url = "insertUrl.do?name="+name+
"&url="+text+"&time"+new Date() ;
//2¡¢´´½¨xmlHttpRequest¶ÔÏó
x ......
ÆÊÎö AJAX »Ø·¢
ÈôҪʹ ASP.NET Ò³Ãæ³ÉΪ²¿·Ö³ÊÏÖµÄÒ³Ã棬Ê×ÏȱØÐëÏòÒ³ÃæÌí¼ÓÒ»¸ö½Å±¾¹ÜÀíÆ÷£¬È»ºóͨ¹ýʹÓà UpdatePanel ¿Ø¼þ½øÐзâ×°£¬´Ó¶ø¶¨Òå¿É¶ÀÁ¢¸üеÄÇøÓò¡£ÀýÈ磺
< ?xml:namespace prefix = asp />
< asp:ScriptManager runat="server">< /asp:ScriptManager>
< asp:UpdatePanel id=Upda ......
1¡¢´´½¨
XMLHttpRequest
¶ÔÏóµÄÒ»¸öʵÀý
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if ( ......
ÒÔÎÒÒÔǰдµÄÒ»¸öÁ·Ï°AJAXµÄ»áÔ±×¢²áÒ³ÃæΪÀý¡£
ÏÂÃæÕâЩÖ÷ÒªÊÇÔÚÊäÈëÓû§Ãû£¬¹â±êÀ뿪ÊäÈë¿ò¾Í½øÐÐÅжϸÃÓû§ÃûÊÇ·ñºÏ·¨µÄajax·½·¨¡£
£¨1£©Xmlhttprequest AJAXÖ®ºËÐÄ
function S_Xmlhttprequest(){
if(window.ActiveXObject) //IE
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
else if(window.XmlHTTPRe ......