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

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µÄ¹ýÂËÆ÷£¬´úÂëÈçÏ£º
view plaincopy to clipboardprint?
<?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> 
    <welc


Ïà¹ØÎĵµ£º

jqueryÖÐajaxÒì²½·µ»ØÊý¾Ý¸ñʽ×ܽá


dataÀàÐÍ
js´úÂ룺
$.post("getmaterial.do?method=getmaterial",
{name:name},
function (data) {
});
ÆäÖÐgetmaterial.do?method=getmaterialÊÇÇëÇóµÄurl£¬{name:name}ÊÇ´«µÝµ½ºǫ́µÄ²ÎÊý£¬¿ÉÒÔÓÃ
request.getParameter("name");»ñÈ¡£¬dataÊǺǫ́´«µÝ¹ýÀ´µÄÊý¾Ý¡£
action´úÂ룺
response.setContentType( ......

¶Ôajax·ÖÒ³µÄ×ܽá


<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"Cambria Mat ......

ajax״ֵ̬´óÈ«

0**£ºÎ´±»Ê¼»¯
1**£ºÇëÇóÊÕµ½£¬¼ÌÐø´¦Àí
2**£º²Ù×÷³É¹¦ÊÕµ½£¬·ÖÎö¡¢½ÓÊÜ
3**£ºÍê³É´ËÇëÇó±ØÐë½øÒ»²½´¦Àí
4**£ºÇëÇó°üº¬Ò»¸ö´íÎóÓï·¨»ò²»ÄÜÍê³É
5**£º·þÎñÆ÷Ö´ÐÐÒ»¸öÍêÈ«ÓÐЧÇëÇóʧ°Ü
100——¿Í»§±ØÐë¼ÌÐø·¢³öÇëÇó
101——¿Í»§ÒªÇó·þÎñÆ÷¸ù¾ÝÇëÇóת»»HTTPЭÒé°æ±¾
200——½»Ò ......

ajaxѧϰ±Ê¼Ç1

<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 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ