AJAX¼¼ÊõʵÏÖStrutsУÑé¿ò¼Ü
ʵʱÊý¾ÝÑéÖ¤ÊÇAJAX¼¼ÊõµÄÒ»´óÓÅÊÆÖ®Ò»¡£Í¨¹ýÓ¦Óô˼¼Êõ£¬strutsÑéÖ¤¿ò¼Ü½«ÔöÇ¿struts MVC£¬²¢Ê¹WebÓ¦ÓóÌÐò¸ü½Ó½üÓÚ×ÀÃæÓ¦ÓóÌÐò¡£
´ËÑéÖ¤¿ò¼ÜÓÃÓÚÑéÖ¤×ֶΡ£ÓÐÐí¶àÔÚWebÓ¦ÓóÌÐòÉϽøÐÐÑéÖ¤µÄ·½·¨¡£ÕâЩ·½·¨¿É·ÖΪÁ½Àࣺ·þÎñÆ÷¶Ë·½·¨ºÍ¿Í»§¶Ë·½·¨¡£StrutsÑéÖ¤¿ò¼ÜÊÇÃæÏò»ùÓÚJavaµÄWebÓ¦Óû·¾³µÄ×î¼Ñ¿ò¼ÜÖ®Ò»¡£ËüÄܹ»ÅäÖÃÓ¦ÓóÌÐò£¬·½·¨ÊÇʹÓ÷þÎñÆ÷¶ËÑéÖ¤ºÍ´íÎóÏûÏ¢£¬´Ë´íÎóÏûÏ¢ÔÚ´¦ÀíÇëÇóʱ³ÊÏÖÔÚµ÷ÓõÄÑéÖ¤Á÷³ÌÉÏ£¬Ëü»¹Äܹ»½øÐпͻ§¶ËÑéÖ¤£¬·½·¨ÊÇʹÓÃÇëÇóÒ³ÃæÉϳÊÏÖµÄJavaScript¡£
AJAXÊÇÒ»ÖÖJavaScript¼¼Êõ£¬ËüÄܹ»Òì²½ºô½Ð·þÎñÆ÷²¢»ñÈ¡XMLÎĵµ£¬ÕâÀàÎĵµ×î½ü·Ç³£Á÷ÐС£ÆäÓÃ;֮һ¾ÍÊÇʵʱÊý¾ÝÑéÖ¤¡£
±¾ÎĹØעʹÓÃAJAXÔöÇ¿ÏÖÓÐstrutsÑéÖ¤¿ò¼Ü¡£±ØÐ뿪·¢¼¸¸ö×é¼þ£¨ÀýÈç¿ØÖÆÆ÷£©£¬ÒÔÑ¡ÔñÑéÖ¤¿ò¼Ü£¬²¢³ÊÏÖÌض¨¸ñʽµÄÏûÏ¢£¨ÓÃÓÚ¿Í»§¶Ë£©ºÍ±êÇ©¿â£¨´¦Àí´íÎóÏûÏ¢³ÊÏÖ£©¡£
±ØÒªÌõ¼þ
ÐèÒªÒ»¸ö¾ßÓÐEclipseºÍTomcatÓ¦Ó÷þÎñÆ÷µÄWindowsϵͳ¡£ÇëÈ·¶¨ÒÑÔÚ²Ù×÷ϵͳÖÐ×¢²áÁËMSXML 3.0 ActiveX¶ÔÏó¡£»¹ÐèÒªStruts¿â(http://struts.apache.org)ºÍJDOM¿â(www.jdom.org)£¬ÒÔÓÃÓÚXML¿ª·¢£¨²Î¼ûͼ1ºÍͼ2£©¡£
·þÎñÆ÷¶Ë³¡¾°StrustsActionServlet
ÎÒÃDZØÐëÀ©Õ¹À´×Ôorg.apache.struts.action.ActionServletµÄÀ࣬ÒÔ»ñµÃservletMapping±äÁ¿£¬´Ë±äÁ¿´æ´¢¹ØÓÚÈçºÎÕë¶Ô¶¯×÷Àཫ¸ÃÀ©Õ¹¸ñʽ»¯Îªä¯ÀÀÆ÷µØÖ·ÐÎʽµÄ¶¯×÷·¾¶µÄÐÅÏ¢¡£µ±Ìí¼Ó´úÂëʱ£¬ÎÒÃDZØÐ뽫web.xmlÅäÖÃΪӦÓ÷þÎñÆ÷µÄWebÓ¦ÓóÌÐòÃèÊö·û¡£
web.xmlÅäÖÃÈçÏ£º
¡¡¡¡...
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>net.sf.struts.servlet.StrutsActionServlet</servlet-class>
...
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
...
StrutsActionServlet Java´úÂëÈçÏ£º
public class StrutsActionServlet extends the ActionServlet.
{
public String getServletMapping() {
return this.servletMapping;
}
}
AjaxValidationRequestProcessor
ÒªÔÚµÚÒ»²½ÖÐÖ§³ÖÏÖÓÐStruts¿ò¼Ü£¬ÎÒÃDZØÐëÀ©Õ¹À´×ÔStrutsÈí¼þ°üµÄRequestProcessor¡£ÎÒÃDZØÐ붨ÖÆ»¯´ËÇëÇó´¦ÀíÆ÷£¬ÒòΪÎÒÃDZØÐëÅбð½«ÈçºÎ½øÐÐÑéÖ¤£¨Í¨¹ýʹÓÃÏÖÓÐStruts¿ò¼Ü£¬»¹ÊÇÀûÓÃAJAX¸ÅÄ£¬»¹ÒòΪÎÒÃǽ«ÔÚ·þÎñÆ÷ºÍ¿Í»§¶ËÖ®¼äÖƶ©Ò»¸öÓйØÈçºÎ½âÊÍÏûÏ¢µÄÆõÔ¼¡£ÔÚÏûÏ¢³ÊÏÖ·½Ã棬ÎÒÃ
Ïà¹ØÎĵµ£º
¸Õµ÷ÊÔ³ÌÐòµÄʱºò±¨´íºóÈ»ºóÕҵĽâ¾ö·½·¨£¬ÏÖÔÚ·¢³öÀ´´ó¼Ò½è¼ø¡£
-----------------------
´íÎóÌáʾ£º
ÔËÐÐʱ´íÎó 800a01b6
¶ÔÏó²»Ö§³Ö´ËÊôÐÔ»ò·½·¨: Response.CharSet
---------------------------------------------------------------------
(°Ù¶Èһϣ¬»¹ÓкܶàÈËÓöµ½Í¬ÑùµÄ´íÎó)
Micros ......
Ò»¸ö¼òµ¥ajax repeater·ÖÒ³demo ¸Ä½ø°æ. ´úÂëÈçÏÂ..
<a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="getData(0)">1</a>
<a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="getData(1)">2< ......
ʲôÊÇ AJAX?
¡¡¡¡AJAX (Òì²½ JavaScript ºÍ XML) ÊǸöвúÉúµÄÊõÓï,רΪÃèÊöJavaScriptµÄÁ½ÏîÇ¿´óÐÔÄÜ.ÕâÁ½ÏîÐÔÄÜÔÚ¶àÄêÀ´Ò»Ö±±»ÍøÂ翪·¢ÕßËùºöÂÔ,Ö±µ½×î½üGmail, Google suggestºÍgoogle MapsµÄºá¿Õ³öÊÀ²ÅʹÈËÃÇ¿ªÊ¼Òâʶµ½ÆäÖØÒªÐÔ.
¡¡¡¡ÕâÁ½Ïî±»ºöÊÓµÄÐÔÄÜÊÇ:
¡¡¡¡ÎÞÐèÖØÐÂ×°ÔØÕû¸öÒ³Ãæ±ãÄÜÏò·þÎñÆ÷·¢ËÍÇëÇó.
¡¡¡ ......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat=" ......