?? goumai.jsp
字號:
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<jsp:directive.page import="com.hygj.bean.*"/>
<jsp:directive.page import="com.hygj.service.*"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>商品購買頁面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
//獲得參數(shù)
String id=request.getParameter("productId");
//判斷參數(shù)是否存在
if(id==null){
response.sendRedirect("index.jsp");
}
else{
//執(zhí)行數(shù)據(jù)庫查詢
ProductsBean product=new ProductsService().getById(Integer.parseInt(id));
//判斷商品是否存在
if(product==null){
response.sendRedirect("index.jsp");
}
else{
//判斷是否有數(shù)量的參數(shù)
String num="1";
if(request.getParameter("shuliang")!=null){
num=request.getParameter("shuliang");
}
//顯示商品具體信息,同時提醒用戶進行購買
%>
商品名稱:<%=product.getProductName() %><br>
商品單價:<%=product.getUnitPrice() %><br>
<form action="CarServlet" method="post">
<input type="hidden" name="productId" value="<%=product.getProductId() %>">
請輸入購買數(shù)量:<input type="text" name="shuliang" value="<%=num %>" size="3"><font color="red">(*請輸入正整數(shù))</font><br>
<br>
<input type="submit" value="購買"><input type="reset" value="取消">
</form>
<%
}
}
%>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -