首页 > 学院 > 开发设计 > 正文

基于wap协议的wml开发示例,在OpenWeve测试下通过。

2019-11-18 15:07:42
字体:
来源:转载
供稿:网友

  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>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表