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

struts2 + jquery + json ½øÐÐajaxÇëÇó


ÏîÄ¿ÖÐÏëÓÃajax£¬ÓÚÊÇÔÚÍøÉÏ°ÇÁËn¶à×ÊÁÏ£¬·¸ÁËn¶à´íÎ󣬴ӽñÌìÉϰൽÏÖÔÚÒ»Ö±ÔÚ´¦ÀíÕâ¸öÎÊÌ⣬ÖÕÓÚ»¹ÊÇ°ÑËü½â¾öÁË¡£
 
µ±ÎÒ¿´µ½Ò³ÃæµÄajaxÏÔʾºó£¬ÎÒÐË·ÜÒì³££¬ÎªÁ˼Ǽ×Ô¼ºÑ§Ï°µÄajaxÀú³Ì£¬Ò²ÎªÁËÈøü¶àµÄÈËÉÙ×ßÍä·£¬ÌØд´ËÒ»ÎÄÒÔ¼ÇÖ®£¡
 
·Ï»°²»ËµÁË£¬ÎªÁ˸üºÃµÄÀí½â£¬ÎÒÖØ×öÁËÒ»¸öСµÄÏîÄ¿£¬ÒÔ¼ÓÉîÓ¡Ïó¡£ÏÖÔÚ¾ÍÒÔÕâ¸öСÏîÄ¿¿ªÊ¼ÎÒÃǵÄajaxÖ®Âá£
 
µÚÒ»²½£º´´½¨ ajax Java WebÏîÄ¿¡£
 
µÚ¶þ²½£º¼ÓÈëstruts2µÄjar°ü£¬ÕâÀïÐèÒªËĸö°ü freemarker.jar  ognl.jar  struts2-core.jar  commons-fileupload.jar  commons-io.jar   xwork-core-2.1.6.jar£¨Õâ¸ö°ü¼ÓÉÏ°æ±¾ºÅ£¬ÊÇÒòΪÏÂÎÄÒªÌáµ½Ëü£©£¬ÕâÁù¸ö°üÊÇstruts±ØÐëÒÀÀµµÄjar°ü£¬Ê²Ã´ºÃ˵µÄ¡£
 
µÚÈý²½£ºÐ޸Ġweb.xml ¼ÓÈë strutsµÄ¹ýÂËÆ÷£¬´úÂëÈçÏ£º
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>



<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

 
µÚËIJ½£º¼ÓÈëjsonµÄ°ü£¬ÕâÀïÐèÒªÁ½¸ö£ºjson-lib.jar  jsonplugin.jar ÕâÀïҪעÒâºÜÖØÒªµÄÒ»µã£¬ÒòΪjson´óÁ¿ÒýÓÃÁËApache commonsµÄ°ü£¬ËùÒÔÕâÀïÒªÒ»²¢¼ÓÈ룬ÐèÒªµÄcommons°ü¹²4¸ö£¬³ýÁËcommonsµÄ°üÍ⣬»¹ÐèÒªÒýÈëÒ»¸ö ezmorphµÄ°ü£¬ËùÒÔÕâÒ»²½Ò»¹²ÒªÒýÈë7¸ö°ü£¬ÁгöÈçÏ£ºcommons-collections.jar  commons-lang.jar  commons-beanutils.jar  commons-logging.jar  ezmorph.jar ÔÙ¼ÓÉÏjsonµÄÁ½¸ö°ü¹²Æ߸ö£¬Ò»´ÎÐÔ¼ÓÈë¡£


Ïà¹ØÎĵµ£º

Ajax¶¨Ê±Ë¢ÐÂÒ³Ãæ

var xmlHttp;
var flag = false;
function createXMLHttpRequest()
{
  if(window.ActiveXObject)
  {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  else if(window.XMLHttpRequest)
  {
  xmlHttp=new XMLHttpRequest();
  }
}
fu ......

Java Web»ù´¡£ºµÚ¶þÊ®¶þ½² Ajax½»»¥¼òµ¥ÊµÀý

±¾ÎÄÄÚÈÝÕª×Ô£º¡¶Java Web¿ª·¢½Ì³Ì——ÈëÃÅÓëÌá¸ßƪ£¨JSP+Servlet£©¡·
ÏÂÃæÒÔ×¢²á¹ý³ÌÖÐÓû§ÃûÊÇ·ñ´æÔÚµÄÑé֤ΪÀý½éÉÜAJAXµÄÓ¦Óá£
¹¦ÄÜÃèÊö£ºÓû§×¢²áµÄÓû§Ãû²»ÔÊÐíÖظ´£¬ËùÒÔÔÚÓû§ÌύʱºòÐèÒªÅжϡ£ÎªÁËÈÃÓû§ÔçÖªµÀ½á¹û£¬ÔÚÓû§ÊäÈëÓû§ÃûÖ®ºó¾ÍÓ¦¸Ã½øÐÐÅжϣ¬¿ÉÒÔ²ÉÓÃAJAX½øÐд¦Àí¡£
¼ÙÉ裺ΪÁ˼ò»¯´ú ......

ajaxÖÆ×÷±íµ¥Ñé֤ʾÀý

 
ajaxµÄ¹¦ÄÜÖ÷ÒªÊÇÓ¦ÓÃÔÚjsÉÏ£¬ajax¶ÔaspûʲôҪÇó£¬aspÖ»¸ºÔðÔÚºǫ́ÏÔʾ¼°²Ù×÷·þÎñ¶ËµÄÊý¾Ý¡£
¿ÉÒÔÏñÏÂÃæÕâÑù˼¿¼£º
1.д±íµ¥µÚÒ»ÏÈçÓû§Ãû£©
2.onblurʼþ(ʧȥ½¹µã)·¢Éúʱ¿ªÊ¼ÑéÖ¤£¬onblur="checkusername()"
3.js·¢Ò»¸öÇëÇó¸øµÚÒ»¸öasp(¼Ù¶¨Îªajaxusername.asp)Èç¹û´ÓÊý¾Ý¿âÖÐÕÒµ½ÁËÕâ¸öÓû§£¬¸ø³ö1 ......

ajax½øÐÐÓû§µÄÓÐЧÐÔ¼ì²âʾÀý

ajax½øÐÐÓû§µÄÓÐЧÐÔ¼ì²âʾÀý
1¡¢  ÊäÈëÓò£º
»áÔ±µÄÓÐЧÐÔ¼ì²é£º
     <input type="text" name="username">&nbsp;&nbsp;<input type="button" value="¼ì²é" onclick="return check();">
2¡¢  JavaScript½Å±¾£º
var xmlHttp;
    //´´½¨XMLHttpRequest ......

jQuery Ajax È«½âÎö

±¾ÎĵØÖ·: jQuery Ajax È«½âÎö
±¾ÎÄ×÷ÕߣºQLeelulu
תÔØÇë±êÃ÷³ö´¦£¡
jQueryȷʵÊÇÒ»¸öͦºÃµÄÇáÁ¿¼¶µÄJS¿ò¼Ü£¬ÄÜ°ïÖúÎÒÃÇ¿ìËٵĿª·¢JSÓ¦Ó㬲¢ÔÚÒ»¶¨³Ì¶ÈÉϸıäÁËÎÒÃÇдJavaScript´úÂëµÄÏ°¹ß¡£
·Ï»°ÉÙ˵£¬Ö±½Ó½øÈëÕýÌ⣬ÎÒÃÇÏÈÀ´¿´Ò»Ð©¼òµ¥µÄ·½·¨£¬ÕâЩ·½·¨¶¼ÊǶÔjQuery.ajax()½øÐзâ×°ÒÔ·½±ãÎÒÃÇʹÓõķ½·¨£¬µ±È»£¬Èç¹ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ