Ajax ºÍ REST£¬µÚ 1 ²¿·Ö
2006 Äê 11 ÔÂ 09 ÈÕ
·þÎñÆ÷¶Ë Web Ó¦ÓóÌÐòÒò²ÉÓø»Ó¦ÓóÌÐòÄ£Ðͺͽ»¸¶¸öÐÔ»¯ÄÚÈݶø¾ß±¸ÁËÈÚÈëʽ£¨immersive£© µÄÌص㣬ÕâÖÖÌصãԽͻ³ö£¬Ó¦ÓóÌÐò¼Ü¹¹¶Ô Web ¼Ü¹¹·ç¸ñ REST£¨Representational State Transfer£©µÄÎ¥±³¾ÍÔ½¶à¡£ÕâÖÖÎ¥±³»á½µµÍÓ¦ÓóÌÐòµÄ¿ÉÉìËõÐÔ£¬Ôö¼Óϵͳ¸´ÔÓÐÔ¡£Í¨¹ýÓë REST Ï໥е÷£¬Ajax ¼Ü¹¹½«Ê¹ÈÚÈëʽ Web Ó¦ÓóÌÐòÏû³ýÕâЩ¸ºÃæÓ°Ï죬¾¡Ïí REST ÄÇЩ³öÉ«µÄÌØÐÔ¡£
ÔÚ¶Ì¶Ì 15 ÄêÖУ¬World Wide Web ÒѾ´ÓÒ»ÏîÑо¿ÊµÑé³É³¤ÎªÏÖ´úÉç»áµÄ¼¼ÊõÖ§Öù¡£×î³õ·¢Ã÷ Web µÄÄ¿µÄÊÇʹÈËÃÇ¿ÉÒÔÇáËÉ·¢²¼ºÍÁ´½ÓÐÅÏ¢£¬ÏÖÔÚËüÒѾ·¢Õ¹ÎªÈí¼þÓ¦ÓóÌÐòµÄ¿ÉÐÐƽ̨¡£µ«Ëæ×ÅÓ¦ÓóÌÐòͨ¹ýʹÓø»Ó¦ÓóÌÐòÄ£ÐͺÍÉú³É¸öÐÔ»¯ÄÚÈݶø»ñµÃÁ˸ü¶àµÄÈÚÈëÐÔ£¬ËüÃǵļܹ¹¶Ô Web ¼Ü¹¹·ç¸ñ REST£¨Representational State Transfer£©µÄÎ¥±³Ò²Ô½À´Ô½¶à¡£ÕâÖÖÎ¥±³»á½µµÍÓ¦ÓóÌÐòµÄ¿ÉÉìËõÐÔ£¬Ôö¼Óϵͳ¸´ÔÓÐÔ¡£
ÐÂÐ赀 Ajax Web ¿Í»§»ú¼Ü¹¹·ç¸ñÈÃÈÚÈëʽ Web Ó¦ÓóÌÐòÓë REST ¼Ü¹¹·ç¸ñе÷Ò»Ö¡£Ê¹ËüÃÇ¿ÉÒÔ¾¡Ïí REST ÄÇЩ³öÉ«µÄÌØÐÔ£¬Í¬Ê±ÓÖÏû³ýÁËÓ¦ÓóÌÐòÎ¥±³ REST ×¼Ôòʱ´øÀ´µÄ²»Á¼ÌØÐÔ¡£±¾ÎĽ«½éÉÜΪÈÚÈëʽ Web Ó¦ÓóÌÐò³É¹¦½áºÏ Ajax ºÍ REST µÄ·½·¨ÓëÔÒò¡£
Çë·ÃÎÊ Ajax ¼¼Êõ×ÊÔ´ÖÐÐÄ£¬ÕâÊÇÓÐ¹Ø Ajax ±à³ÌÄ£ÐÍÐÅÏ¢µÄһվʽÖÐÐÄ£¬°üÀ¨ºÜ¶àÎĵµ¡¢½Ì³Ì¡¢ÂÛ̳¡¢blog¡¢wiki ºÍÐÂÎÅ¡£ÈκÎÐÂÐÅÏ¢¶¼ÄÜÔÚÕâÀïÕÒµ½¡£
REST£ºWeb ¼Ü¹¹
¾¡¹Ü World Wide Web ÊÇÔÚÊýÊ®ÄêµÄÏà¹ØÑо¿»ù´¡ÉϽ¨Á¢ÆðÀ´µÄ£¬µ«ËüµÄÓÐЧµ®ÉúÈÕÆÚÊÇ 1990 Äê 12 Ô£¬µ±Ê± Tim Berners-Lee Íê³ÉÁË Web Ö÷Òª×é¼þµÄ¹¤×÷ÔÐÍ£ºÍ³Ò»×ÊÔ´±êʶ·û£¨URI£©¡¢HTTP¡¢HTML¡¢ä¯ÀÀÆ÷ºÍ·þÎñÆ÷¡£Web ±»Ñ¸ÃͲÉÓã¬Ô¶Ô¶³¬¹ýÁËÏÈÇýÕßÃǵÄÔ¤ÆÚ¡£ÔÚ Roy Fielding ×î³öÃûµÄϵÁÐÎÄÕÂÖУ¨Çë²Î¿´ ²Î¿¼×ÊÁÏ£©£¬ËûÃèÊöÁË×Ô¼ºµ±Ê±µÄÐÄÇ飺
“¾¡¹Ü¶ÔÆä³É¹¦¸Ðµ½Ð˷ܲ»ÒÑ£¬µ«ÊÇ Internet ¿ª·¢ÕßÉçÇøÖ𽥿ªÊ¼µ£ÐÄ£¬Web ʹÓõÄÕâÖÖ¿ìËÙÔö³¤£¬ÒÔ¼°ÔçÆÚ HTTP µÄһЩ׾ÁÓµÄÍøÂçÌØÐÔ£¬»á¿ìËÙѹµ¹ Internet »ù´¡ÉèÊ©ËùÄܳе£µÄÈÝÁ¿£¬´Ó¶øµ¼ÖÂͻȻµÄ±ÀËú¡£”
“Ò»Öּܹ¹ÔÚÉè¼Æʱ¾ÍÓ¦¸Ã¿¼Âǵ½Ò»×éÌØÐÔ£¬ÈÃËü¿ÉÒÔÂú×ãÉõÖÁ³¬Ô½ÏµÍ³µÄÐèÇ󡣺öÂÔÕâЩÌØÐÔ¿ÉÄܻᵼÖºóÆÚ±ä¸ü¸ÉÈÅÕû¸ö¼Ü¹¹£¬¾ÍÏñÊÇʹÓÃÒ»ÉÈÂäµØ´°È¥È¡´ú³ÐÖØǽ»áÆÆ»µÕû¸ö½¨Öþ½á¹¹µÄ¿É¿¿ÐÔ¡£” —— Roy Fielding
Fielding ºÍÆäËûÈË¶Ô Web ¼Ü¹¹¼°ÆäÊÇ·ñÄܹ»×ãÒÔÖ§³Ö¸÷ÖÖÀ©Õ¹ºÍÓ÷¨ÖØнøÐÐÁËÉóÊÓ¡£ÕâÖÖÖØÐÂÉóÊÓµÄÓÐÐνá¹û°üÀ¨¸üÐÂÖ
Ïà¹ØÎĵµ£º
3.4Àí½â¼Ì³Ð
Ò»£®»ùÓÚÔÐ͵ļ̳Уº
²½Ö裺
(1)ÔÚ×ÓÀ๹Ô캯ÊýÖе÷ÓûùÀ๹Ô캯Êý£¬´Ó¶ø¼Ì³Ð»ùÀàµÄÊôÐÔ¡£
(2)½«»ùÀàµÄÒ»¸öÐÂʵÀý¸³¸ø×ÓÀ࣬´Ó¶ø¼Ì³Ð»ùÀàµÄ·½·¨¡£
Samples.Cat=function()
{
Samples.Pet.call(this);
}
Sample ......
1. ʵÏÖ¶ÔÊôÐ﵀ Ajax ÐÞ¸Ä:
1). ·¢Ë굀 ajax ÇëÇóÖÐÐèÒª°üº¬ÄÄЩÐÅÏ¢ÄØ
¢Ù. ÒªÐ޸ĵÄÔ±¹¤µÄ id.
¢Ú. ÒªÐ޸ĵÄÊôÐÔµÄÃû×Ö.
¢Û. ÒªÐ޸ĵÄÊôÐÔµÄÖµ.
......
//==================>¡¾index.jsp¡¿===============================
<%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<% String path=request.getContextPath(); %>
<%@page import="com.sinoest.dfrf.orm.pojo.Mainmenu"%>
<%@page import="com.si ......
var httpRequest = false;
var mesdivs = null
function sendRequest(url, mesdiv) {
mesdivs = mesdiv;
httpRequest = false;
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
......