欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

dojo 之基礎(chǔ)篇(三)之向服務(wù)器發(fā)送數(shù)據(jù)

 更新時間:2007年03月24日 00:00:00   作者:  
向服務(wù)器發(fā)送數(shù)據(jù)有g(shù)et和post兩種.

首先,要將body中的html代碼替換為

  <button dojoType="Button" widgetId="helloButton">Hello World!</button>
<br>
請輸入名稱: <input type="text" id="name">
不輸入數(shù)據(jù),怎么提交數(shù)據(jù)呢.
  1. get
    我們只要將基礎(chǔ)篇(二)中的:
       function helloPressed()
    {
    dojo.io.bind({
    url: 'response.txt',
    handler: helloCallback
    });
    }
    替換為:
       function helloPressed()
    {
    dojo.io.bind({
    url: 'HelloWorldResponseGET.jsp',
    handler: helloCallback,
    content: {name: dojo.byId('name').value }
    });
    }
    即可.其中的url不用說也明白了吧.是相對路徑.也就是說在HelloWorld.html的當前目錄
    下應(yīng)該有一個 HelloWorldResponseGET.jsp 文件. handler還是一樣,處理返回的數(shù)據(jù),
    如果有的話.
    content即為要發(fā)送的數(shù)據(jù). 其中名稱為name,name的值為你所輸入的值.

    這樣,我們可以在jsp中寫入簡單的代碼來獲得這個值,以下為jsp中的代碼

    <%
    /*
    ' HelloWorldResponseGET.jsp
    ' --------
    '
    ' 打印name的值.
    '
    */

    response.setContentType("text/plain");
    %>
    Hello <%= request.getParameter("name") %> ,歡迎來到dojo世界!
  2. Post
    這種方法即為在form表單提交提交數(shù)據(jù).

    相應(yīng)的html代碼為:
      <button dojoType="Button" widgetId="helloButton">Hello World!</button>
    <br>
    <form id="myForm" method="POST">
    請輸入名稱: <input type="text" name="name">
    </form>
    dojo代碼為:
       function helloPressed()
    {
    dojo.io.bind({
    url: 'HelloWorldResponsePOST.jsp',
    handler: helloCallback,
    formNode: dojo.byId('myForm')
    });

    }
    這里將content屬性變?yōu)榱薴ormNode屬性.

    jsp的代碼不變.
到此,dojo的基礎(chǔ)篇告一段落. 這些內(nèi)容來自dojo的官方網(wǎng)站. 更詳細的內(nèi)容請參考官網(wǎng).
http://dojo.jot.com/WikiHome/Tutorials/HelloWorld

相關(guān)文章

最新評論