点击这里给我发消息 点击这里给我发消息
首页 > 行业资讯 > Wap>详细内容

基于wap协议的wml开发示例

添加时间:2010-1-5
    相关阅读: 开发 SQL

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="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>

本文作者:
咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册