熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

wml頁面傳遞變量具體代碼

2013-11-13 10:08:35  來源: .NET編程 

  一起來看代碼          wapTestjsp
        <%@ page language=java import=javautil* contentType=text/vndwapwml;charset=GBK%>
        <%
        String path = requestgetContextPath();
        String basePath = requestgetScheme()+://+requestgetServerName()+:+requestgetServerPort()+path+/;
        %>
        <?xml version= Encoding=GBK?>
        <!DOCTYPE wml PUBLIC //WAPFORUM//DTD WML //EN
        _xml>
        <wml>
        <head>
        <meta httpequiv=contentType content=text/vndwapwml/>
        <meta httpequiv=Expires content= />
        <meta httpequiv=CacheControl content=nocache/>
        </head>
        <card id=list title=choose company>
        <select name=company>
        <option onpick=#sa>索愛</option>
        <option onpick=#nokia>Nokia</option>
        </select>
        </card>
        <card id=sa title=索愛>
        <do type=accept label=OK>
        <go #test></go>
        </do>
        <select name=type>
        <option value=索愛>索愛</option>
        <option value=索愛>索愛</option>
        </select>
        </card>
        <card id=nokia title=Nokia>
        <do type=accept label=OK>
        <go #test></go>
        </do>
        <select name=type>
        <option value=Nokia>Nokia</option>
        <option value=Nokia>Nokia</option>
        </select>
        </card>
        <card id=test title=postfield>
        <p>型號:$type</p>
        <do type=accept label=submit>
        <go method=post>
        <postfield name=company value=$type/>
        </go>
        </do>
        </card></wml>

  servlet
        路徑:wapTest

            public void doGet(HttpServletRequest request HttpServletResponse response)
        throws ServletException IOException
        {
             responsesetContentType(text/vndwapwml;charset=gbk);
             PrintWriter out = responsegetWriter();
             outprint(<wml>);
            if(requestgetParameter(company)!=null)
            {
                outprint(<card><p>company is:+requestgetParameter(company));
                outprint(</p></card>);
            }
            outprint(</wml>);
            outflush();
            outclose();
        }

  當然jsp就可以通過url傳遞<a >jsp</a>


From:http://tw.wingwit.com/Article/program/net/201311/12689.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.