wml和jsp的后台交互

[color=red]test2.wml的代码如下:[/color]<?xml version="1.0"?>
<!-- created by WAPtor (http://www.waptop.net/) -->
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<!-- THIS IS THE FIRST CARD IN THE DECK -->
<card id="MainCard" title="This is a first card">
<p align="center">
Hello ,what is your name?
<input name="n" />
<br/>
Are you a boy or a girl?
<select name="s1">
<option value="am a boy">I am a boy</option>
<option value="am a girl">I am a girl</option>
</select>
<br/>
which tutorial do you like?
<select name="s2" multiple="true">
<option value="p1">part1</option>
<option value="p2">part2</option>
<option value="p3">part3</option>
<option value="p4">part4</option>

</select>
<anchor>
<go method="get" [color=red]href="t.jsp"[/color]>
<postfield name="post1" value="$(n)"/>
<postfield name="post2" value="$(s1)"/>
<postfield name="post3" value="$(n2)"/>
</go>
submit

</anchor>
</p>
</card>
</wml>

[color=red]t.jsp的代码如下:[/color]<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 't.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
<%
String s1= request.getParameter("post1");
String s2= request.getParameter("post2");
String s3= request.getParameter("post3");
out.println(s1);


out.println(s2);
out.println(s3);
%>
</body>
</html>
注意要点:1.[color=red]$[/color]是获取同一个wml下不同card里面的定义的变量。
2.在NMIT下的模拟器中遇到错误,错误内容是:WML encoder:charData/Space not allowed in content,其实每一个在card内必须有<p></p>才不会出错。
3.创建一个tomcat的webapps文件夹中创建一个 名字叫wap的文件夹,将编写好的wml程序和jsp程序放到该文件夹中,然后启动tomcat服务器。然后就可以在winwap中通过http://localhost:8080/wap/test2.wml访问。
4.访问要在winwap 下访问,由于NMIT不支持.jsp页面,所有NMB4.0无法测试到结果。如果在test2.wml 点击提交后跳转到winwap的主页,则要进行注册。
5.[color=red]#[/color] 可以用于卡片的跳转 eg:<go href="[color=red]#[/color]card2"/>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值