基于wap协议的wml开发示例,在OpenWeve测试下通过。
2008-01-05 08:45:38 来源:WEB开发网核心提示:index.jsp<%@ page contentType="text/vnd.wap.wml;charset=gb2312"%><%@ page import="ite.com.*,java.util.*"%><?xml version="
index.jsp
****************
<%@ page contentType="text/vnd.wap.wml;charset=gb2312"%>
<%@ page import="ite.com.*,java.util.*"%>
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd" >
<wml>
<card id="maincard" title="龙行WAP">
<img src="http://www.QQread.com/java/images/csj.gif" alt="pic" align="middle"/>
<center>娱乐场</center>
<p align="left">
<%
List rslist=new ArrayList();
DBManager dbm=new DBManager();
rslist=dbm.Select_Data("select iokesort,iokename from ioketype where tn=0");
for(int i=0;i<rslist.size();i++){
out.PRintln("<a href="indexlist.jsp?card="+((ArrayList)rslist.get(i)).get(0)+"">"+((ArrayList)rslist.get(i)).get(1)+"</a><br/>");
}
dbm=null;
%>
</p>
</card>
</wml>
indexlist.jsp
****************
<%@ page contentType="text/vnd.wap.wml;charset=gb2312"%>
<%@ page import="ite.com.*,java.util.*"%>
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd" >
<wml>
<card id="maincard" title="龙行WAP">
<p align="left">
<%
String cardid=request.getParameter("card");
if (cardid!=null&&(!cardid.equals(""))){
String sql="select iokesort,iokename from ioketype where tn="+cardid;
// out.println(" <small><a href="list.jsp?card="+cardid+"&iokesort="+rs.getInt("iokesort")+"">"+rs.getString("iokename")+"</a></small><br/>");
List rslist=new ArrayList();
DBManager dbm=new DBManager();
rslist=dbm.Select_Data(sql);
for(int i=0;i<rslist.size();i++){
out.println(" <small><a href="list.jsp?card="+cardid+"&iokesort="+((ArrayList)rslist.get(i)).get(0)+"">"+((ArrayList)rslist.get(i)).get(1)+"</a></small><br/>");
}
dbm=null;
}
%>
<a href="index.jsp">返回</a><br/>
</p>
</card>
</wml>
list.jsp
******************
<%@ page language="java" contentType="text/vnd.wap.wml;charset=gb2312" %>
<%@ page import="ite.com.*,java.util.*"%>
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd" >
<wml>
<card id="listcard" title="龙行科技笑话">
<p align="left">
<%
String card=request.getParameter("card");
String iokesort=request.getParameter("iokesort");
int RowCount; //记录总数
int PageSize=8; //一页显示的记录数
int PageCount; //总页数
int PageNo; //待显示页码
String Page= request.getParameter("page");//取得要显示的页码
if(Page==null){
PageNo=1;
}else{
PageNo= java.lang.Integer.parseInt(Page);
if(PageNo<1) PageNo=1;
}
List rslist=new ArrayList();
DBManager dbm=new DBManager();
String sql="select id,title from iokecontent where iokesort="+iokesort;
//取得符合条件的总记录数
RowCount=dbm.Select_Count_SQL(sql);
if(RowCount!=0){
//计算总页数
PageCount=(RowCount+PageSize-1)/PageSize;
rslist=dbm.queryByPage_SQL_OrderBy(RowCount,PageSize,PageNo,sql+" order by id desc");//按id降序排序
for(int i=0;i<rslist.size();i++){
out.println("<small><a href="view.jsp?card="+card+"&iokesort="+iokesort+"&id="+((ArrayList)rslist.get(i)).get(0)+"&page="+PageNo+"">"+((ArrayList)rslist.get(i)).get(1)+"</a></small><br/>");
}
if(PageNo>1){
%>
<a href="list.jsp?&card=<%=card%>&iokesort=<%=iokesort%>&page=<%=(PageNo-1)%>">上一页</a>
<%}
if(PageNo<PageCount){
%>
<a href="list.jsp?&card=<%=card%>&iokesort=<%=iokesort%>&page=<%=(PageNo+1)%>">下一页</a>
<%}
}else{
out.println("<b>对不起此类栏目没有新增内容!</b>");
}
sql="select iokename from ioketype where iokesort="+card;
String iokename="";
rslist=dbm.Select_Data(sql);
for(int i=0;i<rslist.size();i++){
iokename=((ArrayList)rslist.get(i)).get(0).toString();
}
dbm=null;
%>
<br/>
<a href="indexlist.jsp?card=<%=card%>">返回<%=iokename%></a><br/>
<a href="index.jsp">返回首页</a><br/>
</p>
</card>
</wml>
view.jsp
************************
<%@ page language="java" contentType="text/vnd.wap.wml;charset=gb2312" %>
<%@ page import="ite.com.*,java.util.*"%>
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd" >
<wml>
<card id="listcard" title="龙行科技笑话">
<p align="left">
<%
String card=request.getParameter("card");
String iokesort=request.getParameter("iokesort");
String id=request.getParameter("id");
String PageNo=request.getParameter("page");
String sql="select info from iokecontent where id="+id;
List rslist=new ArrayList();
DBManager dbm=new DBManager();
rslist=dbm.Select_Data(sql);
for(int i=0;i<rslist.size();i++){
String content=new String("");
content=((ArrayList)rslist.get(i)).get(0).toString();
content=content.replaceAll("<br> <br>","<br/>");
content=content.replaceAll("<br><br>","<br/>");
content=content.replaceAll("<br>","<br/>");
out.println(content+"<br/>");
}
dbm=null;
%>
<a href="list.jsp?card=<%=card%>&iokesort=<%=iokesort%>&page=<%=PageNo%>">返回</a><br/>
</p>
</card>
</wml>
- ››基于IP地址的vsftp服务器
- ››基于MySQL 水平分区的优化示例
- ››基于CentOS5的Linux下pptp和openvpn的搭建及配置
- ››基于JavaScript的网页版塔防游戏
- ››基于Android平台 QQ大战360手机游戏爆红
- ››基于Windows Azure的云计算应用设计
- ››基于AES算法实现对数据的加密
- ››基于SoPC目标板Flash编程设计的创建及应用
- ››基于SolidWarks齿轮机构的运动分析与仿真
- ››基于Windwos Server 2008故障转移群
- ››基于JavaScript的REST客户端框架
- ››基于JavaScript和CSS的Web图表框架横向对比
更多精彩
赞助商链接