zipcode.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:7k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html;charset=gb2312"%>
  2. <%@ page import = "java.net.URLEncoder"%>
  3. <%@ page import="org.jdom.*"%>
  4. <%@ page import="org.jdom.output.*"%>
  5. <%@ page import="org.jdom.input.*"%>
  6. <%@ page import="java.io.*"%>
  7. <%@ page import="java.util.*"%>
  8. <%@ page import="java.sql.*"%>
  9. <%@ page import="cn.js.fan.util.*"%>
  10. <%@ page import="cn.js.fan.db.*"%>
  11. <%@ page import="cn.js.fan.web.*"%>
  12. <html>
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  15. <title>无标题文档</title>
  16. <link href="common.css" rel="stylesheet" type="text/css">
  17. <%@ include file="inc/nocache.jsp"%>
  18. </head>
  19. <body leftmargin="0" topmargin="3">
  20. <jsp:useBean id="fchar" scope="page" class="cn.js.fan.util.StrUtil" />
  21. <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  22.   <tr>
  23.     <td>
  24.         <table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#C4DAFF" class="stable">
  25.         <form name="form1" method="post" action="zipcode.jsp"> <tr> 
  26.             <td height="20" class="stable">城市、区号、邮编查询</td>
  27.           </tr>
  28.           <tr> 
  29.             <td height="26" class="stable">查询关键字: 
  30.               <input name="keyword" type="text" size=12 id="keyword"> 
  31.               查询选项: <select name="searchmode" id="searchmode">
  32.                 <option value="1" selected>查找城市邮编</option>
  33.                 <option value="2">邮编查找城市</option>
  34.                 <option value="1">查找城市区号</option>
  35.                 <option value="3">区号查找城市</option>
  36.               </select> <input type="submit" name="Submit" value="查 找"> <input type="reset" name="Submit2" value="重 写"> 
  37.             </td>
  38.           </tr></form>
  39.         </table>
  40.     </td>
  41.   </tr>
  42.   <tr>
  43.     <td><table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#666666" bordercolordark="#FFFFFF" bgcolor="#d6d3ce">
  44.       <tr>
  45.         <td width="22%">
  46.           <div align="center"><font color="#FF0000">省洲名称</font></div>
  47.         </td>
  48.         <td width="30%">
  49.           <div align="center"><font color="#FF0000">地区名称</font></div>
  50.         </td>
  51.         <td width="26%">
  52.           <div align="center"><font color="#FF0000">邮政编码</font></div>
  53.         </td>
  54.         <td width="22%">
  55.           <div align="center"><font color="#FF0000">电话区号</font></div>
  56.         </td>
  57.       </tr>
  58. <%
  59. String keyword = StrUtil.Unicode2GB(request.getParameter("keyword"));
  60. if (keyword==null || keyword.trim().equals(""))
  61. ;
  62. else {
  63. Conn conn = new Conn(Global.defaultDB);
  64. try {
  65.     int searchmode = Integer.parseInt(request.getParameter("searchmode"));
  66.   String province = "";
  67.   String city = "";
  68.   String zip = "";
  69.   String yb = "";
  70.   String sql = "";
  71.   switch (searchmode)
  72.   {
  73.    case 1:sql = "select province,city,postcode,qh from postcode where city="+fchar.sqlstr(keyword);
  74. break;
  75. case 2:sql = "select province,city,postcode,qh from postcode where postcode="+fchar.sqlstr(keyword);
  76. break;
  77. case 3:sql = "select province,city,postcode,qh from postcode where qh="+fchar.sqlstr(keyword);
  78. break;
  79. case 4:sql = "select province,city,postcode,qh from postcode where province="+fchar.sqlstr(keyword);
  80. break;
  81.   }
  82.   ResultSet rs = conn.executeQuery(sql);
  83.   if (rs!=null)
  84.   {
  85.    while (rs.next())
  86. province = rs.getString(1);
  87. city = rs.getString(2);
  88. zip = rs.getString(3);
  89. yb = rs.getString(4);
  90. %>
  91.       <tr>
  92.         <td width='22%'><%=province%></td>
  93.         <td width='30%' ><%=city%></td>
  94.         <td width='26%' ><%=zip%></td>
  95.         <td width='22%' ><%=yb%></td>
  96.       </tr>
  97. <%  }
  98. rs.close();
  99. rs = null;
  100.   }
  101. }
  102. catch (Exception e) {
  103.    out.print(e.getMessage());
  104. }
  105. finally {
  106. if (conn!=null) {
  107. conn.close();
  108. conn = null;
  109. }   
  110. }
  111. }
  112. %>
  113.     </table></td>
  114.   </tr>
  115.   <tr>
  116.     <td align="center"><img src="images/chinamap.gif" width="469" height="367" border="0" usemap="#Map"></td>
  117.   </tr>
  118. </table>
  119. <map name="Map">
  120. <area shape="poly" coords="68,80" href="#">
  121. <area shape="rect" coords="74,117,114,133" href="?searchmode=4&keyword=%D0%C2%BD%AE">
  122. <area shape="rect" coords="76,217,117,232" href="?searchmode=4&keyword=%CE%F7%B2%D8">
  123. <area shape="rect" coords="153,181,192,197" href="?searchmode=4&keyword=%C7%E0%BA%A3">
  124. <area shape="rect" coords="224,135,288,152" href="?searchmode=4&keyword=%C4%DA%C3%C9%B9%C5">
  125. <area shape="rect" coords="390,88,420,102" href="?searchmode=4&keyword=%BC%AA%C1%D6">
  126. <area shape="rect" coords="368,112,396,128" href="?searchmode=4&keyword=%C1%C9%C4%FE">
  127. <area shape="rect" coords="334,127,363,141" href="?searchmode=4&keyword=%B1%B1%BE%A9">
  128. <area shape="rect" coords="318,131,332,160" href="?searchmode=4&keyword=%BA%D3%B1%B1">
  129. <area shape="rect" coords="334,143,364,155" href="?searchmode=4&keyword=%CC%EC%BD%F2">
  130. <area shape="rect" coords="293,154,309,182" href="?searchmode=4&keyword=%C9%BD%CE%F7">
  131. <area shape="rect" coords="332,166,363,183" href="?searchmode=4&keyword=%C9%BD%B6%AB">
  132. <area shape="rect" coords="245,159,264,188" href="?searchmode=4&keyword=%C4%FE%CF%C4">
  133. <area shape="rect" coords="227,176,244,207" href="?searchmode=4&keyword=%B8%CA%CB%E0">
  134. <area shape="rect" coords="205,227,243,245" href="?searchmode=4&keyword=%CB%C4%B4%A8">
  135. <area shape="rect" coords="218,245,248,259" href="?searchmode=4&keyword=%D6%D8%C7%EC">
  136. <area shape="rect" coords="270,192,286,222" href="?searchmode=4&keyword=%C9%C2%CE%F7">
  137. <area shape="rect" coords="301,194,331,214" href="?searchmode=4&keyword=%BA%D3%C4%CF">
  138. <area shape="poly" coords="339,210,349,203,364,236,351,237" href="?searchmode=4&keyword=%B0%B2%BB%D5">
  139. <area shape="poly" coords="354,196,364,188,387,217,375,227" href="?searchmode=4&keyword=%BD%AD%CB%D5">
  140. <area shape="rect" coords="292,225,323,242" href="?searchmode=4&keyword=%BA%FE%B1%B1">
  141. <area shape="rect" coords="197,294,235,311" href="?searchmode=4&keyword=%D4%C6%C4%CF">
  142. <area shape="rect" coords="250,271,279,286" href="?searchmode=4&keyword=%B9%F3%D6%DD">
  143. <area shape="rect" coords="296,252,315,283" href="?searchmode=4&keyword=%BA%FE%C4%CF">
  144. <area shape="rect" coords="331,250,347,280" href="?searchmode=4&keyword=%BD%AD%CE%F7">
  145. <area shape="rect" coords="357,262,372,292" href="?searchmode=4&keyword=%B8%A3%BD%A8">
  146. <area shape="rect" coords="266,300,298,318" href="?searchmode=4&keyword=%B9%E3%CE%F7">
  147. <area shape="rect" coords="311,298,343,315" href="?searchmode=4&keyword=%B9%E3%B6%AB">
  148. <area shape="rect" coords="306,347,337,363" href="?searchmode=4&keyword=%BA%A3%C4%CF">
  149. <area shape="rect" coords="403,280,418,313" href="?searchmode=4&keyword=%CC%A8%CD%E5">
  150. <area shape="rect" coords="370,233,396,249" href="?searchmode=4&keyword=%D5%E3%BD%AD">
  151. <area shape="rect" coords="392,214,419,228" href="?searchmode=4&keyword=%C9%CF%BA%A3">
  152. <area shape="rect" coords="384,47,424,62" href="?searchmode=4&keyword=%BA%DA%C1%FA%BD%AD">
  153. </map>
  154. </body>
  155. </html>