WML表單提交

WML表單提交 

 程序代碼
關鍵詞:<input name="keyword" title="keyword" type="text" format="*M" emptyok="false" maxlength="12"/><br/>
<anchor title="搜索">搜索
    <go href="http://wap.mzwu.com/" method="get">
        <postfield name="key" value="$(keyword:escape)"/>
    </go>
</anchor> 

程序代碼
關鍵詞:<input name="keyword" title="keyword" type="text" format="*M" emptyok="false" maxlength="12"/><br/>
<do type="accept" label="搜索" name="do01">
    <go href="http://wap.mzwu.com/" method="get">
        <postfield name="key" value="$(keyword:escape)"/>
    </go>
</do>

上邊兩種方式都可以用來提交表單,下邊說下幾個僞指令的含義:

$(keyword:escape):指示微瀏覽器將非文本數字的字符替換成十六進制代碼;
$(keyword:unesc):指示微瀏覽器用相應的字符替換十六進制代碼;
$(keyword:noesc):指示微瀏覽器準確的按照字符出現的樣子處理他們;

WML似乎沒有類型爲hidden的input,如有些參數需隱藏發送,可直接在go中設置: 

程序代碼
關鍵詞:<input name="keyword" title="keyword" type="text" format="*M" emptyok="false" maxlength="12"/><br/>
<anchor title="搜索">搜索
    <go href="http://wap.mzwu.com/" method="get">
        <postfield name="key" value="$(keyword:escape)"/>
        <postfield name="mid" value="3"/>
    </go>
</anchor>
=================================================================================================
index.wml文件,提交到testreceive.jsp文件
    
<?xml version="1.0"?>
<!doctype wml public "-//wapforum//dtd wml 1.1//en" "http://www.wapforum.org/dtd/wml_1.1.xml">
<wml>
    <card title="信息發佈">
        <do type="accept" label="提交" name="do1">
            <go href="testreceive.jsp" method="post">
                <postfield name="infotype" value="$(infotype)"/>  
                <postfield name="infotitle" BACKGROUND: #ffff00; COLOR: #000000">infotitle"/>
                <postfield name="infocontent" value="$infocontent"/>
                <postfield name="SFoodName" value="$SFoodName"/>
            </go>
        </do>
        
        <p>請選擇你要發佈信息的種類:
            <br/>
                <select name="infotype">
                    <option value="1001">貨運</option>
                    <option value="1002">傢俱家電</option>
                    <option value="1003">電腦數碼</option>
                    <option value="1004">手機通訊</option>
                    <option value="1005">汽車</option>
                    <option value="1006">創投信息</option>
                    <option value="1007">其它</option>
                    <option value="1008">家政</option>
                    <option value="1009">搬家</option>
                    <option value="10010">出租</option>
                    <option value="10011">求租</option>
                    <option value="10012">招聘信息</option>
                    <option value="10013">司機中介</option>
                    <option value="10014">待聘</option>
                </select>
            <br/>
            請輸入要發佈的標題:<br/>
            <input name="infotitle" type="text" size="30" maxlength="60"/>
            <br/>
            請輸入要發佈的內容:<br/>
            <input name="infocontent" type="text" size="40" maxlength="60"/>
            <br/>
            <select title="選擇圖片" name="imgurl">
                <option value="images/128_128a.gif">圖一</option>
                <option value="images/128_128b.gif">圖二</option>
            </select>
        </p>
        
        
        <p align="left">
            請輸入菜名<br/>
            <input title="abc" name="SFoodName" maxlength="20" /><br/>
        </p>
        
        <p>
            <anchor title="確定">Go to rec
                <go method="post" href="testreceive.jsp">
                    <postfield name="infotype" value="$(infotype)"/>  
                    <postfield name="infotitle" BACKGROUND: #ffff00; COLOR: #000000">infotitle"/>
                    <postfield name="infocontent" value="$infocontent"/>
                    <postfield name="SFoodName" value="$SFoodName"/>
                </go>
            </anchor>
        </p>
        
        <p>
            <br/>
        </p>
    </card>
</wml>

testreceive.jsp

<%
response.setContentType("text/vnd.wap.wml;charset=gb2312");

out.println("<?xml version=/"1.0/" encoding=/"gb2312/"?>");

out.println("<!DOCTYPE wml PUBLIC /"-//WAPFORUM//DTD WML 1.1//EN/" /"http://www.wapforum.org/DTD/wml_1.1.xml/">");

%>
<%@ page language="java" contentType="text/vnd.wap.wml;charset=gb2312"%>
<wml>
<card id="card1" title="信息發佈">
<p>
接收到的信息如下:
<%
out.println(request.getParameter("infotype"));
out.println(request.getParameter("infotitle"));
out.println(request.getParameter("infocontent"));
out.println(request.getParameter("SFoodName"));

%>
</p>
</card>
</wml>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章