buybook.jsp
来自「jsp学习的好资料」· JSP 代码 · 共 33 行
JSP
33 行
<%@ page contentType="text/html;charset=gb2312" %>
<%@ include file="incoming/common.jsp"%>
<%@ include file="incoming/check.jsp"%>
<%
String isbn = new String(request.getParameter("isbn").trim().getBytes("ISO-8859-1"));
String buynum = new String(request.getParameter("buynum").trim().getBytes("ISO-8859-1"));
Vector buylist = (Vector)session.getValue("shopcar");
int ismatch = 0;
Book book = new Book(isbn, Integer.parseInt(buynum));
if (buylist == null)
{
buylist = new Vector();
buylist.addElement(book);
}
else
{
for(int i=0; i<buylist.size(); i++)
{
Book _book =(Book)buylist.elementAt(i);
if(_book.getIsbn().equals(book.getIsbn()))
{
_book.setBuynum(_book.getBuynum()+book.getBuynum());
buylist.setElementAt(_book,i);
ismatch = 1;
}
}
if(ismatch==0)
buylist.addElement(book);
}
session.putValue("shopcar", buylist);
response.sendRedirect("shopcar.jsp");
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?