📄 sta_display.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>显示所有站点</title>
<style type="text/css">
<!--
body {
background-image: url(../Picture/index-top_2.gif);
margin-left: 100px;
}
.style1 {
font-size: 16px;
font-weight: bold;
}
a:link {
color: #0000CC;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #990000;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #FF0000;
}
-->
</style></head>
<body>
<%
Connection con;
String statement="";
ResultSet result;
int count=0;
String all_station[]=new String[2000];
String detail="";
String station1="";
String station2="";
int flag=0,mark=0,flag1=0;
String temp="";
// Comparator cmp = Collator.getInstance(java.util.Locale.CHINA);
try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
try{
con=DriverManager.getConnection("jdbc:odbc:nbos","","");
Statement sql=con.createStatement();
statement="select * from bus";
result=sql.executeQuery(statement);
if(result.next())
{ detail=result.getString("Detail");
StringTokenizer str=new StringTokenizer(detail,"->");
all_station[0]=str.nextToken();
count++;
while(str.hasMoreTokens())
{ temp=str.nextToken();
for(int countfirst=0,mark1=0;countfirst<count&&mark1==0;countfirst++)
{ if(all_station[countfirst].equals(temp))
{ mark1=1;
flag1=0;
}
else
flag1=1;
}
if(flag1==1)
{ all_station[count]=temp;
// out.println(all_station[count]);
count++;
}
}//endwhile
}//endif
//遍历数据库,把所有站点不重复地放入数组all_station[]数组中
while(result.next())
{ //把每一条记录放入临时变量detail中
detail=result.getString("Detail");
StringTokenizer str1=new StringTokenizer(detail,"->");
//out.println(detail);
//对每一条记录的每一个站点进行比较
while(str1.hasMoreTokens())
{ mark=0;//恢复mark的值,以便比较下一条记录
StringTokenizer str2=new StringTokenizer(str1.nextToken()," ");
station2=str2.nextToken();
//注:count是随着程序的执行而不断的增加
for(int k=0;k<count&&mark==0;k++)
{
//当站点相同时用mark的值来结束循环,
if(station2.indexOf(all_station[k])!=-1||all_station[k].indexOf(station2)!=-1)
{ mark=1;
flag=0;
}
else
flag=1;//如果全都不相同时,用flag值来跟踪
} //endfor
//把不重复的站点放入数组中,count加一,
if(flag==1)
{ all_station[count]=station2;
count++;
}//endif
} //endwhile
} //endwhile
// out.println(all_station[5]);
result.close();
// Arrays.sort(all_station, cmp);
// out.println(count);
//out.println("dsafd");
if(count>0)
{
%>
<table width="615" border="1">
<tr>
<td colspan="6"><div align="center"><strong>数据库中共有<font color="FFOOOO"><%=count%></font>个站点</strong></div></td>
</tr>
<tr background="../Picture/topbg.gif">
<td background="../Picture/topbg.gif" colspan="6"><div align="center"><span class="style1">所有站点信息</span></div></td>
</tr>
<tr background="../Picture/l33.gif">
<td width="49" height="17" background="../Picture/l33.gif">编号</td>
<td width="144" background="../Picture/l33.gif">站点</td>
<td width="41" background="../Picture/l33.gif">编号</td>
<td width="128" background="../Picture/l33.gif">站点</td>
<td width="51" background="../Picture/l33.gif">编号</td>
<td width="162" background="../Picture/l33.gif">站点</td>
</tr>
<% int i=0;
while(i<count)
{// out.println(count);
%>
<tr background="../Picture/l33.gif">
<td background="../Picture/l33.gif"> <%=i+1%></td>
<td background="../Picture/l33.gif"> <a href="../resultquery2.jsp?query2=<%=all_station[i]%>" target="_blank"><%=all_station[i]%></a></td>
<td background="../Picture/l33.gif"> <%=i+2%></td>
<td background="../Picture/l33.gif"> <a href="../resultquery2.jsp?query2=<%=all_station[i+1]%>" target="_blank"><%=all_station[i+1]%></a></td>
<td background="../Picture/l33.gif"> <%=i+3%></td>
<td background="../Picture/l33.gif"> <a href="../resultquery2.jsp?query2=<%=all_station[i+2]%>" target="_blank"><%=all_station[i+2]%></a></td>
</tr><% i=i+3;
} %>
<tr background="../Picture/bottombg.gif">
<td background="../Picture/bottombg.gif" colspan="6"> </td>
</tr>
</table>
<% }
} catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -