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·µ»Ø¶à¸öÖµµÄʱºò£¬¿ÉÒÔÓÃxml£¬Ò²¿ÉÒÔÓÃjson
jsonʵÀý
<html>
<head>
<title>AjaxTest</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
& ......
AjAx.js
var bCheckUserPass = false;
var StrType;
function checkUsers(StrTmp)
{
var oB = window.document.all.nam
StrType=StrTmp
if (oB.length == 0) re ......
±¾ÎĵØÖ·: jQuery Ajax È«½âÎö
±¾ÎÄ×÷ÕߣºQLeelulu
תÔØÇë±êÃ÷³ö´¦£¡
jQueryȷʵÊÇÒ»¸öͦºÃµÄÇáÁ¿¼¶µÄJS¿ò¼Ü£¬ÄÜ°ïÖúÎÒÃÇ¿ìËٵĿª·¢JSÓ¦Ó㬲¢ÔÚÒ»¶¨³Ì¶ÈÉϸıäÁËÎÒÃÇдJavaScript´úÂëµÄÏ°¹ß¡£
·Ï»°ÉÙ˵£¬Ö±½Ó½øÈëÕýÌ⣬ÎÒÃÇÏÈÀ´¿´Ò»Ð©¼òµ¥µÄ·½·¨£¬ÕâЩ·½·¨¶¼ÊǶÔjQuery.ajax()½øÐзâ×°ÒÔ·½±ãÎÒÃÇʹÓõķ½·¨£¬µ±È»£¬Èç¹ ......
<html>
<head>
<title></title>
</head>
<mce:script type="text/javascript"><!--
var xmlHttp = false;
try{
xmlHttp = new XMLHttpRequest();
}catch(trymicrosoft){
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHT ......
Web¿ª·¢Õß²»»á×¢Òâµ½ÓÉ “AJAX(Asynchronous JavaScript And
XML)”Ëù´øÀ´µÄ¼¤Çé¡£²»·ÑÁ¦Æø¾ÍÄÜ´´½¨ÏñGoogle
SuggestÄÇÑùµÄÖÇÄÜÍøÕ¾»òÕßÏñGmailÄÇÑù»ùÓÚWebµÄÓ¦ÓóÌÐò£¬ÕâÔںܴó³Ì¶ÈÉÏÒª¹é¹¦ÓÚÕâÖÖ¼¼Êõ¡£È»¶ø£¬°éËæ×ÅAJAXÓ¦ÓóÌÐòµÄ·¢Õ¹£¬ÎÒÃÇ·¢
ÏÖÁËËüµÄһЩ²»×ãÖ®´¦£¬ÎÒÃÇ·¢ÏÖËüµÄ°²È«Â©¶´Ò²ÔÚÖð½¥±ä´ó£¬¾ÍÏ ......