想不想get新技能酷炫一下,今天图老师小编就跟大家分享个简单的WML——XML标记语言开发实例详细解析教程,一起来看看吧!超容易上手~
【 tulaoshi.com - Web开发 】
本文主要介绍WML的相关知识,如何开发WAP应用程序。<xml version='1.0'>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<?xml version='1.0'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml> <card id="Login" title="Login">
<do type="accept" label="Password">
<go href="#Password"/>
</do>
<p>
UserName:
<select name="name" title="Name:">
<option value="John Doe">John Doe</option>
<option value="Paul Smith">Paul Smith</option>
<option value="Joe Dean">Joe Dean</option>
<option value="Bill Todd">Bill Todd</option>
</select>
</p>
</card>
<card id="Password" title="Password:">
<do type="accept" label="Results">
<go href="#Results"/>
</do>
<p>
Password:
<input type="text" name="password"/>
</p>
</card>
<card id="Results" title="Results:">
<p>
You entered:<br/>
Name: $(name)
<br/>
Password: $(password)<br/>
</p>
</card>
</wml>
<?xml version='1.0'?>
<DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML
1.1//EN" "http://www.wapforum.org /DTD/wml_1.1.xml">
<wml>
<card id="Order" title="Query Inventory">
<p>
<select name="Items" title="Items">
<option value="Books">Books</option>
<option value="Music">Music</option>
<option value="Video">Video</option>
<option value="Software">
Software</option>
</select>
</p>
<do type="accept" label="Query">
<go href="http://222.28.218.222:8088/wap/wapservlet" method="get">
<postfield name="Items" value="$(Items)"/>
</go>
</do>
</card>
</wml>
package com.j2medev.mingjava;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class WapServlet extends HttpServlet
{
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String select = request.getParameter("Items");
response.setContentType("text/vnd.wap.wml");
PrintWriter out = response.getWriter();
out.println("<?xml version="1.0"?>");
out.println("<!DOCTYPE wml PUBLIC"-//WAPFORUM//DTD WML 1.1//EN"");
out.println(""http://www.wapforum.org/DTD/wml_1.1.xml">");
out.println("<wml>"); out.println("<card title="test">");
out.println(" <p align="center">"); out.println("you selected "+select);
out.println("</p>"); out.println("</card>"); out.println("</wml>");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
doGet(request,response);
}
}
来源:http://www.tulaoshi.com/n/20160219/1608232.html
看过《WML——XML标记语言开发实例详细解析》的人还看了以下文章 更多>>