欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
基于Struts的AJAX

首先,我們仍然是對Struts應用來(lái)做配置,仍然是在struts-config,xml文件里做配置,如下:

 <action type="com.ajax.CheckAction"
     scope="request" path="/ajax/check">
     <forward name="success" path="/check.jsp"/>
 </action>


跟普通的Struts應用的配置一樣,只是沒(méi)有ActionForm的配置。下面是Action類(lèi):

 package com.ajax;
 
 import java.io.PrintWriter;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.struts.action.Action;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
 import org.apache.struts.action.DynaActionForm;
 
 /**
  * @author Administrator
  *
  * TODO To change the template for this generated type comment go to
  * Window - Preferences - Java - Code Style - Code Templates
  */
 public class CheckAction extends Action
 {
  public final ActionForward execute(ActionMapping mapping, ActionForm form,
           HttpServletRequest request,
           HttpServletResponse response)
   throws Exception
   {
  System.out.println("haha...............................");
  String username= request.getParameter("username");
  System.out.println(username);
  String retn;
  if("educhina".equals(username)) retn = "Can‘t use the same name with the old use,pls select a difference...";
  else retn = "congraducation!you can use this name....";
  PrintWriter out=response.getWriter();
           out.write(retn);
           out.close();
  return mapping.findForward("success");
   }
  public static void main(String[] args)
  {
  }
 }

我們可以看到里面的邏輯跟上例中Servlet里的邏輯一樣。最后,我們來(lái)看看JSP:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
 <title>Check.html</title>
 
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="this is my page">
 
 <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
 
 </head>
 <script type="text/javascript">
  var http_request = false;
  function send_request(url) {//初始化、指定處理函數、發(fā)送請求的函數
   http_request = false;
  
file://開(kāi)始初始化XMLHttpRequest對象
   if(window.XMLHttpRequest) {
file://Mozilla 瀏覽器
  http_request = new XMLHttpRequest();
  if (http_request.overrideMimeType) {//設置MiME類(lèi)別
   http_request.overrideMimeType(‘text/xml‘);
  }
   }
   else if (window.ActiveXObject) { // IE瀏覽器
  try {
   http_request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e) {}
  }
   }
   if (!http_request) { // 異常,創(chuàng )建對象實(shí)例失敗
  window.alert("不能創(chuàng )建XMLHttpRequest對象實(shí)例.");
  return false;
   }
   http_request.onreadystatechange = processRequest;
   // 確定發(fā)送請求的方式和URL以及是否同步執行下段代碼
   http_request.open("GET", url, true);
   http_request.send(null);
  }
  // 處理返回信息的函數
   function processRequest() {
       if (http_request.readyState == 4) { // 判斷對象狀態(tài)
           if (http_request.status == 200) { // 信息已經(jīng)成功返回,開(kāi)始處理信息
               alert(http_request.responseText);
           } else {
file://頁(yè)面不正常
               alert("您所請求的頁(yè)面有異常。");
           }
       }
   }
  function userCheck() {
   var f = document.forms[0];
   var username = f.username.value;
   if(username=="") {
  window.alert("The user name can not be null!");
  f.username.focus();
  return false;
   }
   else {
  send_request(‘a(chǎn)jax/check.do?username=‘+username);
   }
  }
 
 </script>
 <body>
  <form name="form1" action="" method="post">
 User Name:<input type="text" name="username" value=""> 
 <input type="button" name="check" value="check" onClick="userCheck()">
 <input type="submit" name="submit" value="/oblog312/submit">
 </form>
 </body>
 </html>

我們可以看到,JSP基本是一樣的,除了要發(fā)送的url:ajax/check.do?username="+username。 

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
struts原理與實(shí)踐(2)
手把手教你在Eclipse中配置并開(kāi)發(fā)Struts(二)
[翻譯]MyEclipse Struts 快速上手
struts demo Struts1.3
Struts開(kāi)發(fā)指南之工作流程
歡迎光臨 - 琳婕小筑-老貓的理想 - Struts配置說(shuō)明 -
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久