struts2+jquery+json+hibernate+ajaxµÄµÇ½demo
ÓÃstruts2+jquery+json+hibernate+ajax×öÁËÒ»¸öµÇ½µÄdemo¡£
1.jspÒ³Ãæ
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ÎÞ±êÌâÎĵµ</title>
<style type="text/css">
#loginForm label.error
{
padding-left: 16px;
margin-left: 2px;
color:red;
}
input.error, textarea.error
{
border: solid 1px #CD0A0A;
}
</style>
//myAjax.js ºÍ myCheck.js ÊÇÎÒ×Ô¼º¶¨ÒåµÄÓÃÀ´Ìá½»formºÍÑéÖ¤formµÄÁ½¸öjsÎļþ
<link href="style/style.css" rel="stylesheet" type="text/css"/>
<link href="style/thickbox.css" rel="stylesheet" type="text/css"/>
<link href="style/jquery.alerts.css" rel="stylesheet" type="text/css"/>
<script language="javascript" src="js/jquery.min.js"></script>
<script language="javascript" src="js/jquery.validate.js"></script>
<script language="javascript" src="js/jquery.form.js"></script>
<script language="javascript" src="js/myCheck.js"></script>
<script language="javascript" src="js/myAjax.js"></script>
&l
Ïà¹ØÎĵµ£º
×î½üÍøÉÏÌáµÄºÜ¶àµÄÒ»¸öиÅÄî¾ÍÊÇ AJAX ÁË, ÄÇô, AJAX ÊÇʲôÄØ? ÒÔÏÂÄÚÈÝÒýÓÃÍøÉÏ×ÊÁÏ:
AJAXÈ«³ÆΪ“Asynchronous JavaScript and XML”£¨Òì²½JavaScriptºÍXML£©£¬ÊÇÖ¸Ò»ÖÖ´´½¨½»»¥Ê½ÍøÒ³Ó¦ÓõÄÍøÒ³¿ª·¢¼¼Êõ¡£ËüÓлúµØ°üº¬ÁËÒÔϼ¸ÖÖ¼¼Êõ£º
Ajax£¨Asynchronous JavaScript + XML£©µÄ¶¨Òå
»ùÓÚ web±ê×¼£¨sta ......
jspÄÚÖöÔÏó£º
page --java.lang.Object
request --javax.servlet.http.HttpServletRequest
session --javax.servlet.http.HttpSession
application --javax.servlet.ServletContext
response --javax.servlet.http.HttpServletRes ......
AJAX Ö¸Òì²½ JavaScript ¼° XML£¨Asynchronous JavaScript And XML£©¡£
ÄúÓ¦µ±¾ß±¸µÄ»ù´¡ÖªÊ¶
ÔÚ¼ÌÐøѧϰ֮ǰ£¬ÄúÐèÒª¶ÔÏÂÃæµÄ֪ʶÓлù±¾µÄÁ˽⣺
HTML / XHTML
JavaScript
AJAX = Òì²½ JavaScript ¼° XML£¨Asynchronous JavaScript and XML£©
AJAX ²»ÊÇÒ»ÖÖеıà³ÌÓïÑÔ£¬¶øÊÇÒ»ÖÖÓÃÓÚ´´½¨¸üºÃ¸ü¿ìÒÔ¼°½»»¥ÐÔ¸üÇ¿µ ......
JSON²å¼þÌṩÁËÒ»ÖÖÃûΪjsonµÄResultType£¬Ò»µ©ÎªÄ³¸öActionÖ¸¶¨ÁËÒ»¸öÀàÐÍΪjsonµÄResult£¬Ôò¸ÃResultÎÞÐèÓ³Éäµ½ÈκÎÊÓͼ×ÊÔ´¡£ÒòΪJSON²å¼þ»á¸ºÔð½«ActionÀïµÄ״̬ÐÅÏ¢ÐòÁл¯³ÉJSON¸ñʽµÄÊý¾Ý£¬²¢½«¸ÃÊý¾Ý·µ»Ø¸ø¿Í»§¶ËÒ³ÃæµÄJavaScript¡£
¡¡¡¡¼òµ¥µØ˵£¬JSON²å¼þÔÊÐíÎÒÃÇÔÚJavaScriptÖÐÒì²½µ÷ÓÃAction£¬¶øÇÒAction²»ÔÙÐè ......
AJAXÂÒÂë½â¾ö
ÓùýAJAXµÄÅóÓѿ϶¨ÖªµÀjavascriptÊÇʹÓÃUTF-8¹ú¼Ê±àÂ룬¼´Ã¿¸öºº×ÖÓÃ4¸ö×Ö½ÚÀ´´æ´¢£¬µ«ÊÇÕâ¾ÍÔì³ÉÁËÓÃAJAXÀ´sendÊý¾ÝµÄʱºò³öÏÖÂÒÂë¡£
AjaxÂÒÂë²úÉúÖ÷ÒªÓÐ2¸öÔÒò
1. xtmlhttp ·µ»ØµÄÊý¾ÝĬÈϵÄ×Ö·û±àÂëÊÇutf-8£¬Èç¹ûǰ̨ҳÃæÊÇgb2312»òÕßÆäËü±àÂëÊý¾Ý¾Í»á²úÉúÂÒÂë
2. post·½·¨Ìá½»Êý¾Ý ......