spss.jsp
上传用户:xjrzjk
上传日期:2022-07-31
资源大小:1585k
文件大小:4k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=GBK" %>
  2. <%@ page import="java.sql.*"%>
  3. <%
  4.   try{
  5.   //数据库连接
  6.   Class.forName("oracle.jdbc.driver.OracleDriver");
  7.   String strUrl = "jdbc:oracle:thin:@slight:1521:LOCAL";
  8.   String strUser = "eshop";
  9.   String strPassword = "eshop";
  10.   Connection con = DriverManager.getConnection(strUrl, strUser, strPassword);
  11.   Statement st = con.createStatement();
  12.   //得到用户传入的商品信息
  13.   String strName = request.getParameter("Product_Name");
  14.   strName = new String(strName.getBytes("iso8859-1"),"gb2312");
  15.   String strClass = request.getParameter("Product_Class");
  16.   strClass = new String(strClass.getBytes("iso8859-1"),"gb2312");
  17.   String sql = "select * from Product";
  18.   StringBuffer sb = new StringBuffer(sql);
  19.   if (strName.length() >0){
  20.     sb.append(" Where Product_Name like '%");
  21.     sb.append(strName);
  22.     sb.append("%'");
  23.   }else{
  24.     sb.append(" Where Product_Name like '%%'");
  25.   }
  26.   if (strClass.length()>0){
  27.     sb.append(" AND Class_1 like '%");
  28.     sb.append(strClass);
  29.     sb.append("%'");
  30.   }
  31.   ResultSet rs = st.executeQuery(sb.toString());
  32. %>
  33. <html>
  34. <head>
  35. <title>
  36. 商品搜索
  37. </title>
  38. <script language="javascript">
  39.   function openbag(id) { window.open("eshop.asp?cpbm="+id,"","height=200,width=700,left=190,top=0,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");}
  40. </script>
  41. <link rel="stylesheet" type="text/css" href="style.css">
  42. </head>
  43. <body>
  44. <div align="center">
  45.  <table border="0" cellpadding="0" cellspacing="0" width="600"  height="92" >
  46.     <tr>
  47.        <td width="100%" height="70">
  48.            <div align="center">
  49.                <table border="0" cellpadding="0" cellspacing="0" width="100%" height="148" >
  50.                  <tr>
  51.                     <td valign="top">
  52.                       <div align="center">
  53.                            <table border="0" cellspacing="1" width="100%" bordercolorlight="#006699" bordercolordark="#FFFFFF"  height="55" bgcolor="#000000">
  54.                             <tr>
  55.                               <td width="16%" align="center" bgcolor="#006699" height="23"><font color="#FFFFFF">商品编号</font></td>
  56.                               <td width="34%" align="center" bgcolor="#006699" height="23"><font color="#FFFFFF">商品名称</font></td>
  57.                               <td width="18%" align="center" bgcolor="#006699" height="23"><font color="#FFFFFF">会员价</font></td>
  58.                               <td width="17%" align="center" bgcolor="#006699" height="23"><font color="#FFFFFF">详细信息</font></td>
  59.                               <td width="15%" align="center" bgcolor="#006699" height="23"><font color="#FFFFFF">购买</font></td>
  60.                             </tr>
  61. <%
  62.   while (rs.next()){
  63. %>
  64.                             <tr>
  65.                               <td width="16%" align="center" height="28" bgcolor="#EEEEEE"><%=rs.getString("Product_Id")%></td>
  66.                               <td width="34%" align="center" height="28" bgcolor="#EEEEEE" ><%=rs.getString("Product_Name")%></td>
  67.                               <td width="18%" align="center" height="28" bgcolor="#EEEEEE"><%=rs.getDouble("P_NewPrice")%></td>
  68.                               <td width="17%" align="center" height="28" bgcolor="#EEEEEE"><a href="spjj.jsp?ProductNO=<%=rs.getLong("Product_No")%>">详细资料</td>
  69.                               <td width="15%" align="center" height="28" bgcolor="#EEEEEE"><a href='javascript:openbag(<%=rs.getString("Product_Id")%>)'><img style="CURSOR: hand" src="images/mybuy.gif" align="absMiddle" border="0"></a></td>
  70.                             </tr>
  71. <%
  72.   }
  73. %>
  74.                              </table>
  75.                         </div>
  76.   </td>
  77.                     </tr>
  78.                   </table>
  79.                 </div>
  80.               </td>
  81.             </tr>
  82.           </table>
  83.       </div>
  84. </body>
  85. </html>
  86. <%
  87.   }catch(Exception e){
  88.   //错误处理
  89.   throw (e);
  90.   }
  91. %>