比如当我买第一本书时,页面能正常显示所买的书的信息,但当我买另一本书时,页面显示的还是第一本书的信息,希望哪位好心的大侠帮忙看看,不过代码有点长,谢谢!!!
package buyList;
public class buyList {
public String name;
public int id;
public int price;
public int book_number;
public String user_name;
}
book.jsp
<jsp:include page="function.jsp"/>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=book","sa", "11011");
Statement stmt=con.createStatement();
int id=Integer.parseInt(request.getParameter("id"));
String strSQL="SELECT * from book where id="+id;
ResultSet rs = stmt.executeQuery(strSQL);
//out.println(strSQL);
if(rs.next()) {
%>
·············
<td colspan=2 align="center"> <a href="add1.jsp?id= <%=id%>">放入购物车 </a>
| <a href="javascript:close();">关闭窗口 </a>
</tr>
</table>
<% }
rs.close();
%>
add1.jsp