乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      struts2.1.8版如何使用ajax

       Ethan的博客 2011-05-25
      struts2.1.8版如何使用ajax
      2010-07-20 15:32

      1.將struts2-dojo-plugin-2.1.8.1.jar加入lib中
      2.在需要使用標(biāo)簽的jsp文件里寫(xiě)上<%@taglib prefix="sx" uri="/struts-dojo-tags" %>
      3.在<head>標(biāo)簽里寫(xiě)上<sx:head/>


      之后我們就可以開(kāi)始使用struts2的ajax標(biāo)簽了

      需注意的事項(xiàng)
      1、需引入struts2-dojo-plugin-2.1.8.1.jar
      2、頁(yè)面標(biāo)簽的變化如下:
      ajax.jsp
      Java代碼
      1. <%@ page language="java" pageEncoding="UTF-8"%>   
      2. <%@ taglib prefix="s" uri="/struts-tags"%>   
      3. <%@ taglib prefix="sx" uri="/struts-dojo-tags"%><!-- 注意 -->   
      4.   
      5. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">   
      6. <html>   
      7.    <head>         
      8.      <title>Ajax Demo</title>   
      9.      <sx:head/><!-- 注意 -->   
      10.    </head>   
      11.      
      12.    <body>    
      13. <h1>Ajax Dmeo:</h1>   
      14. <div id="show">一個(gè)div</div>   
      15. <s:form namespace="/demo" action="ajax!testAjax" method="post"><!-- 注意 -->   
      16.      <s:textfield name="name"></s:textfield>   
      17.      <sx:submit value="修改上面div的值" targets="show"></sx:submit><!-- 注意 -->   
      18. </s:form>   
      19.    </body>   
      20. </html>  


      Java代碼
      1. package cn.ibeans.demo.web.action;   
      2.   
      3. import org.apache.log4j.Logger;   
      4. import org.apache.struts2.convention.annotation.Namespace;   
      5. import org.apache.struts2.convention.annotation.Result;   
      6. import org.apache.struts2.convention.annotation.Results;   
      7.   
      8. import com.opensymphony.xwork2.ActionSupport;   
      9.   
      10. @Namespace("/demo")   
      11. @Results({   
      12.     @Result(name="ok",location="ajaxResult.jsp")   
      13. })   
      14. public class AjaxAction extends ActionSupport {   
      15.     private static Logger log= Logger.getLogger(AjaxAction.class);   
      16.     private String data;   
      17.   
      18.     public String getData() {   
      19.         return "服務(wù)器的返回值:"+data;   
      20.      }   
      21.   
      22.     public void setData(String data) {   
      23.         this.data = data;   
      24.      }   
      25.        
      26.     public String testAjax() throws Exception{   
      27.          log.info("ajax 調(diào)用成功!");   
      28.         return "ok";   
      29.      }   
      30.   
      31.     @Override  
      32.     public String execute() throws Exception {   
      33.          log.info("ajax 調(diào)用成功!");   
      34.         return super.SUCCESS;   
      35.      }   
      36.        
      37.        
      38. }  


      ajaxResult.jsp:
      Java代碼
      1. <%@ taglib prefix="s" uri="/struts-tags" %>   
      2.   
      3. <%   
      4.      request.setAttribute("decorator", "none");   
      5.      response.setHeader("Cache-Control","no-cache"); //HTTP 1.1   
      6.      response.setHeader("Pragma","no-cache"); //HTTP 1.0   
      7.      response.setDateHeader ("Expires", 0); //prevents caching at the proxy server   
      8.      System.out.println("ajaxResult.jsp is called");   
      9. %>   
      10.   
      11. Result:   <s:property value="data"/><br/>  

      這樣ajaxResult.jsp的內(nèi)容將會(huì)出現(xiàn)在ajax.jsp的id="show"的div中

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類(lèi)似文章 更多