⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goumai.jsp

📁 用jsp和servlet技术运用MVC模式做的购物车小系统源码
💻 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>
    <%
    //获得参数 
    String id=request.getParameter("productId");
    //判断参数是否存在
    if(id==null){
    	response.sendRedirect("index.jsp");
    }
    else{
    	//执行数据库查询
    	ProductsBean product=new ProductsService().getById(Integer.parseInt(id));
    	//判断商品是否存在
    	if(product==null){
    		response.sendRedirect("index.jsp");
    	}
    	else{
    		//判断是否有数量的参数
    		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() %>">
    		请输入购买数量:<input type="text" name="shuliang" value="<%=num %>" size="3"><font color="red">(*请输入正整数)</font><br>
    		<br>
    		<input type="submit" value="购买"><input type="reset" value="取消">
    		</form>
    	<%
    	}
    }    
     %>
  </body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -