日期:2014-05-17  浏览次数:20613 次

求大神帮忙

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page  import="java.sql.*" %>
<html>
  <head>
    <title>测试商品搜索</title>
  </head>
  <body>
    <%@include file="convert.jsp"%>
    <%
      Connection conn=null;
       ResultSet rsAll=null;
      Statement stmt=null;
      try
    {
          Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
          String strConn="jdbc:sqlserver://localhost:1433;DatabaseName=ShopSystem"; 
          String strUser="sa"; 
          String strPassword="sa";
          conn=DriverManager.getConnection(strConn,strUser,strPassword); 
          stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
          String strItem=request.getParameter("item");
          String strContent=Bytes(request.getParameter("co"));
          String strSql="";
          if(strItem==null||strItem=="")
          {
             strSql="select p_id,p_type,p_name,p_price,p_quantity,p_time from product";
          }
          else
          {
            strSql="select p_id,p_type,p_name,p_price,p_quantity,p_time from product where "+strItem.trim()+"LIKE'%"+strContent.trim()+"%'";
          }
          rsAll=stmt.executeQuery("strSql");
   }
    catch(Exception e){e.printStackTrace();}
      %>
      <table width=80% border=1 cellspacing=0 align=center>
      <tr>
      <td><font size=2>商品编号</font></td>
      <td><font size=2>商品类别</font></td>
      <td><font size=2>商品名称</font></td>
      <td><font size=2>商品价格</font></td>
      <td><font size=2>商品数量</font></td>
      <td><font size=2>上架日期</font></td>
      </tr>
      <%
      String str=(String)request.getParameter("page");
      if(str==nu