Spring MVC+Ajax´´½¨ÊµÀý
Java´úÂë
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object cmd,
BindException ex) {
String userId=request.getParamater("userId");
Map userInfoMap=userDao.getUserBaseInfo(userId);
JSONObject object = new JSONObject();
object.put("userInfoMap",userInfoMap);
response.setContentType("text/Xml;charset=gbk");
PrintWriter out = null;
try {
out = response.getWriter();
out.println(object.toString());
}
catch (IOException ex1) {
ex1.printStackTrace();
}finally{
out.close();
}
return nu
Ïà¹ØÎĵµ£º
Ajax(Asynchronous JavaScript and XML)ÊÇÒ»¸ö½áºÏÁËJava¼¼Êõ¡¢XML¡¢ÒÔ¼°JavaScriptµÄ±à³Ì¼¼Êõ£¬¿ÉÒÔÈÃÄã¹¹½¨»ùÓÚJava¼¼ÊõµÄWebÓ¦Ó㬲¢´òÆÆÁËʹÓÃÒ³ÃæÖØÔصĹßÀý¡£
Ajax£¬Òì²½JavaScriptÓëXML£¬ÊÇʹÓÿͻ§¶Ë½Å±¾ÓëWeb·þÎñÆ÷½»»»Êý¾ÝµÄWebÓ¦Óÿª·¢·½·¨¡£ÕâÑù£¬WebÒ³Ãæ²»Óôò¶Ï½»»¥Á÷³Ì½øÐÐÖØмӲ㬾ͿÉÒÔ¶¯Ì¬µØ¸üС£Ê ......
¸Ã¿Ø¼þ¿ÉÒÔʵÏÖÔÚÒ³ÃæÖе¯³öÒ»¸ö´°¿Ú£¬Õâ¸ö´°¿Ú²»ÊÇÒ»¸öеÄä¯ÀÀÆ÷´°¿Ú£¬¶øÊÇÏâǶÔÚÒ³ÃæÖеÄÒ»¸ö²ã¡£
1 ´´½¨Ò»¸ölinkbutton£¬ÓÃÓÚµã»÷´ò¿ª´°¿Ú¡£
2 ÍÏÈëÒ»¸öpanel£¬Õâ¸ö¾ÍÊÇÎÒÃÇÒªµ¯³öµÄ´°¿Ú¡£ËüÒ²¿ÉÒÔÊÇÁ½¸öǶÌ×µÄpanel¡£Àý³ÌÉÏÊÇÕâÑù×öµÄ£¬»¹ÊÇûÓÐÃ÷°×ΪʲôÕâô×ö¡£
3 ÍÏÈëÒ»¸öModalPopupExtender¿Ø¼þ£¬ÔڸÿؼþµÄta ......
¶àÊý Web Ó¦ÓóÌÐò¶¼Ê¹ÓÃÇëÇó/ÏìӦģÐÍ´Ó·þÎñÆ÷ÉÏ»ñµÃÍêÕûµÄ HTML Ò³Ãæ¡£³£³£Êǵã»÷Ò»¸ö°´Å¥£¬µÈ´ý·þÎñÆ÷ÏìÓ¦£¬ÔÙµã»÷ÁíÒ»¸ö°´Å¥£¬È»ºóÔٵȴý£¬ÕâÑùÒ»¸ö·´¸´µÄ¹ý³Ì¡£ÓÐÁË Ajax ºÍ XMLHttpRequest ¶ÔÏ󣬾ͿÉÒÔʹÓò»±ØÈÃÓû§µÈ´ý·þÎñÆ÷ÏìÓ¦µÄÇëÇó/ÏìӦģÐÍÁË¡£±¾ÎÄÖУ¬Brett McLaughlin ½éÉÜÁËÈçºÎ´´½¨Äܹ»ÊÊÓ¦²»Í¬ä¯ÀÀÆ÷µÄ ......
ajax.open·½·¨ÖУ¬µÚ3¸ö²ÎÊýÊÇÉèͬ²½»òÕßÒì²½¡£prototypeµÈjsÀà¿âÒ»°ã¶¼Ä¬ÈÏΪÒì²½£¬¼´ÉèΪtrue¡£
ÏÈ˵ÏÂͬ²½µÄ
Çé¿öÏ£¬js»áµÈ´ýÇëÇ󷵻أ¬»ñÈ¡status¡£²»ÐèÒªonreadystatechangeʼþ´¦Àíº¯Êý¡£
¶øÒì²½ÔòÐèÒª
onreadystatechangeʼþ´¦Àí£¬ÇÒֵΪ4ÔÙÕýÈ·´¦ÀíÏÂÃæµÄÄÚÈÝ
......
ÔÚVisual StudioÖУ¬ËùÓеÄASP.NET 2.0¿Ø¼þ¶¼ÊÇ×Ô¶¨Òå¿Ø¼þ£¬´´½¨×Ô¼ºµÄ×Ô¶¨Òå¿Ø¼þÒ»°ãÐèÒªÍê³ÉÒÔÏÂÈý²½¡£
(1)ÔÚÕ¾µãAPP_CodeÏ´´½¨Ò»¸öÐÂÀࣻ
(2)ÐÞ¸ÄÕâ¸öÀ࣬ÈÃËü³ÉΪWebControlÀà(°üº¬ÔÚSystem.Web.UI.WebControlsÃüÃû¿Õ¼ä)µÄÅÉÉúÀࣻ
(3)ÖØд»ùÀà(¼´WebControlÀà)µÄRenderContents()·½·¨¡£
ÏÂÃæÊÇÒ»¸ö×î¼òµ¥µÄASP.NE ......