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

AJAXʵ¼ùDWRƪ

DWR(Direct Web Remoting)ÊÇÒ»¸öWEBÔ¶³Ìµ÷Óÿò¼Ü.ÀûÓÃÕâ¸ö¿ò¼Ü¿ÉÒÔÈÃAJAX¿ª·¢±äµÃºÜ¼òµ¥.ÀûÓÃDWR¿ÉÒÔÔÚ¿Í»§¶ËÀûÓÃJavaScriptÖ±½Óµ÷Ó÷þÎñ¶ËµÄJava·½·¨²¢·µ»ØÖµ¸øJavaScript¾ÍºÃÏñÖ±½Ó±¾µØ¿Í»§¶Ëµ÷ÓÃÒ»Ñù(DWR¸ù¾ÝJavaÀàÀ´¶¯Ì¬Éú³ÉJavaScrip´úÂë).ËüµÄ×îа汾DWR0.6Ìí¼ÓÐí¶àÌØÐÔÈç:Ö§³ÖDom TreesµÄ×Ô¶¯ÅäÖÃ,Ö§³ÖSpring(JavaScriptÔ¶³Ìµ÷ÓÃspring bean),¸üºÃä¯ÀÀÆ÷Ö§³Ö,»¹Ö§³ÖÒ»¸ö¿ÉÑ¡µÄcommons-loggingÈռDzÙ×÷.
ÒÔÉÏÕª×Ôopen-open£¬¿´Á˼¸Ì죬ȷʵÊÇÒ»¸ö·Ç³£ÓÅÐãµÄÏîÄ¿£¬Ëüͨ¹ý·´É䣬½«java·­Òë³Éjavascript£¬È»ºóÀûÓûص÷»úÖÆ£¬ÇáËÉʵÏÖÁËjavascriptµ÷ÓÃJava´úÂë¡£
Æä´ó¸Å¿ª·¢¹ý³ÌÈçÏ£º
1.±àдҵÎñ´úÂ룬¸Ã´úÂëÊǺÍdwrÎ޹صġ£
2.È·ÈÏÒµÎñ´úÂëÖÐÄÄЩÀà¡¢ÄÄЩ·½·¨ÊÇÒªÓÉjavascriptÖ±½Ó·ÃÎʵġ£
3.±àдdwr×é¼þ£¬¶Ô²½Öè2µÄ·½·¨½øÐзâ×°¡£
4.ÅäÖÃdwr×é¼þµ½dwr.xmlÎļþÖУ¬Èç¹ûÓбØÒª£¬ÅäÖÃconvert£¬½øÐÐjavaºÍjavascriptÀàÐÍ»¥×ª¡£
5.ͨ¹ý·´Éä»úÖÆ£¬dwr½«²½Öè4µÄÀàת»»³Éjavascript´úÂ룬Ìṩ¸øǰ̨ҳÃæµ÷Óá£
5.±àдÍøÒ³£¬µ÷Óò½Öè5µÄjavascriptÖеÄÏà¹Ø·½·¨£¨¼ä½Óµ÷Ó÷þÎñÆ÷¶ËµÄÏà¹ØÀàµÄ·½·¨£©£¬Ö´ÐÐÒµÎñÂß¼­£¬½«Ö´Ðнá¹ûÀûÓûص÷º¯Êý·µ»Ø¡£
6.Ôڻص÷º¯ÊýÖУ¬µÃµ½Ö´Ðнá¹ûºó£¬¿ÉÒÔ¼ÌÐø±àдҵÎñÂß¼­µÄÏà¹Øjavascript´úÂë¡£
ÏÂÃæÒÔÓû§×¢²áµÄÀý×Ó£¬À´ËµÃ÷ÆäʹÓᣣ¨×¢Ò⣬±¾´ÎÀý×ÓÖ»ÊÇÓÃÓÚÑÝʾ£¬ËµÃ÷DWRµÄʹÓã¬ÀàÉè¼Æ²¢²»ÊÇ×îÓŵģ©¡£
1.ÏȽéÉÜÏÂÏà¹ØµÄJavaÀà
User: Óû§À࣬
public class User {
//µÇ½ID£¬Ö÷¼üΨһ
private String id;
//ÐÕÃû
private String name;
//¿ÚÁî
private String password;
//µç×ÓÓʼþ
private String email;
//ÒÔÏ°üº¬getXXXºÍsetXXX·½·¨
.......
}
UserDAO£ºÊµÏÖUserµÄÊý¾Ý¿â·ÃÎÊ£¬ÕâÀï×÷Ϊһ¸öÑÝʾ£¬±àд²âÊÔ´úÂë
public class UserDAO {
//´æ·Å±£´æµÄÊý¾Ý
private static Map dataMap = new HashMap();
//³Ö¾ÃÓû§
public boolean save(User user) {
if (dataMap.containsKey(user.getId()))
return false;
System.out.println("ÏÂÃ濪ʼ±£´æÓû§");
System.out.println("id£º"+user.getId());
System.out.println("password£º"+user.getPassword());
System.out.println("name£º"+user.getName());
System.out.println("email£º"+user.getEmail());
dataMap.put(user.getId(), user);
System.out.println("Óû§±£´æ½áÊø");
return


Ïà¹ØÎĵµ£º

Ajax add_initializeRequest

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<titl ......

ajax °²È«ÐÔ

ÍêÈ«ÊÊÓÃASP.NETµÄÈÏÖ¤»úÖÆ
–¿ÉÒÔʹÓÃFormsAuthentication
•WebService·½·¨¿ÉÒÔ²Ù×÷Cookie
–Impersonation
–PrincipalPermission
WebService7.cs Code
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
usi ......

ajax´«µÝÌØÊâ²ÎÊý

²ÉÓÃAjax´«µÝ²ÎÊý¼ÓºÅ(+)ºÍÓë·ûºÅ(&)ʱºò£¬·þÎñ¶Ë»ñÈ¡µ½µÄ²ÎÊý²¢²»ÈçÒ⣡
(1) "+"ºÅ£ºJavaScript½âÎöΪ×Ö·û´®Á¬½Ó·û£¬ËùÒÔ·þÎñÆ÷¶Ë½ÓÊÕÊý¾Ýʱ"+"»á¶ªÊ§¡£
(2)"&"£ºJavaScript½âÎöΪ±äÁ¿Á¬½Ó·û£¬ËùÒÔ·þÎñÆ÷¶Ë½ÓÊÕÊý¾Ýʱ&·ûºÅÒÔºóµÄÊý¾Ý¶¼»á¶ªÊ§¡£
½â¾ö°ì·¨£ºÔÚ´«µ½·þÎñ¶Ë֮ǰÏȽ«²ÎÊýÖеÄ"+"ºÍ"&"·ûºÅ¶¼± ......

¼òµ¥Ó¦¸ÃajaxÎÞˢлñÈ¡Êý¾Ý

Ajax¿ÉÒÔʵÏÖÍøÒ³µÄ¾Ö²¿Ë¢ÐÂ,ÊÇͨ¹ýJS»ñÈ¡Êý¾Ý,ÔÙ°ÑÊý¾ÝÌí¼Óµ½ÍøÒ³ÖÐ,È»¶øÓÉÓÚä¯ÀÀÆ÷µÄ²»Í¬,³õѧÕߺÜÄÑ×öµ½¼æÈÝÎÊÌâ.
ÕâÀïÎÒÏò´ó¼Ò½éÉÜÒ»Öֺõķ½·¨.ͨ¹ýJQuery²å¼þ.JQuery.jsÎļþ¿ÉÒÔÔÚ¹ÙÍøÉÏÏÂÔØ,»òÕßgoogleÒ²ÐÐ.
Ê×ÏÈÄãÒªÔÚÍøÒ³ÒýÈëJSÎļþ
<script src="../javascript/jquery.js" type="text/javascript"></ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ