14.首页点击商品显示商品详情

1、在index.jsp中传递商品id,在a标签中加入href的内容,href="${pageContext.request.contextPath }/product_findByPid.action?pid=<s:property value="#p.pid"/>"

<s:iterator value="nList" var="p">
									<li>
										<a target="_blank" href="${pageContext.request.contextPath }/product_findByPid.action?pid=<s:property value="#p.pid"/>"><img src="${pageContext.request.contextPath}/<s:property value="#p.image"/>" data-original="http://storage.shopxx.net/demo-image/3.0/201301/4a51167a-89d5-4710-aca2-7c76edc355b8-thumbnail.jpg" style="display: block;"></a>
									</li>
							</s:iterator>

2、ProductAction.java

package cn.xdy.shop.product.action;

import cn.xdy.shop.product.service.ProductService;
import cn.xdy.shop.product.vo.Product;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;


public class ProductAction extends ActionSupport implements ModelDriven<Product>{
	private ProductService productService;
	private Product product = new Product();
	
	public void setProductService(ProductService productService) {
		this.productService = productService;
	}

	public String findByPid(){
		product = productService.findByPid(product.getPid());
		return "findByPid";
	}

	public Product getModel() {
		return product;
	}
	
}

3、ProductService.java中加入findByPid的方法

/**
	 * 根据pid查询商品信息
	 * @param pid
	 * @return
	 */
	public Product findByPid(Integer pid) {
		return productDao.findByPid(pid);
	}
	

4、ProductDao.java中加入 findByPid的方法

/**
	 * 根据ID查询商品
	 * @param pid
	 * @return
	 */
	public Product findByPid(Integer pid) {
		return this.getHibernateTemplate().get(Product.class, pid);
	}

5、Struts.xml配置

<!-- 商品action -->
    	<action name="product_*" class="productAction" method="{1}">
    		<result name="findByPid">/WEB-INF/jsp/product.jsp</result>
    	</action>

6、applicationContext

<!-- 商品类的Action -->
	<bean id="productAction" class="cn.xdy.shop.product.action.ProductAction" scope="prototype">
		<property name="productService" ref="productService"/>
	</bean>

7、Product.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>网上商城</title>
<link href="${pageContext.request.contextPath}/css/common.css" rel="stylesheet" type="text/css">
<link href="${pageContext.request.contextPath}/css/product.css" rel="stylesheet" type="text/css">


</head>
<body>

<div class="container header">
	<div class="span5">
		<div class="logo">
			<a>
				<img src="${pageContext.request.contextPath}/image/r___________renleipic_01/logo.gif" alt="星辰商城">
			</a>
		</div>
	</div>
	<div class="span9">
<div class="headerAd">
					<img src="image\r___________renleipic_01/header.jpg" alt="正品保障" title="正品保障" height="50" width="320">
</div>	</div>
	<%@ include file="menu.jsp" %>
</div><div class="container productContent">
		<div class="span6">
			<div class="hotProductCategory">
						<dl>
							<dt>
								<a href="./蔬菜分类.htm">蔬菜</a>
							</dt>
									<dd>
										<a >无公害蔬菜</a>
									</dd>
									<dd>
										<a>特菜类</a>
									</dd>
									<dd>
										<a>有机蔬菜</a>
									</dd>
									<dd>
										<a>蔬菜套餐</a>
									</dd>
						</dl>
						<dl>
							<dt>
								<a>水果</a>
							</dt>
									<dd>
										<a>国产</a>
									</dd>
									<dd>
										<a>进口</a>
									</dd>
									
						</dl>
						<dl>
							<dt>
								<a >肉类</a>
							</dt>
									<dd>
										<a>猪肉</a>
									</dd>
									<dd>
										<a>牛羊肉</a>
									</dd>
									<dd>
										<a>家禽</a>
									</dd>
									<dd>
										<a>鱼</a>
									</dd>
						</dl>
						<dl>
							<dt>
								<a>蛋、奶及肉制品类</a>
							</dt>
									<dd>
										<a>蛋</a>
									</dd>
									<dd>
										<a>奶</a>
									</dd>
									<dd>
										<a>豆制品</a>
									</dd>
						</dl>
						<dl>
							<dt>
								<a >干果</a>
							</dt>
									<dd>
										<a>干制坚果</a>
									</dd>
									<dd>
										<a>干制果实/果肉</a>
									</dd>
									<dd>
										<a >干制种仁</a>
									</dd>
									<dd>
										<a>    </a>
									</dd>
						</dl>
						<dl>
							<dt>
								<a >古薯杂粮</a>
							</dt>
									<dd>
										<a >米类</a>
									</dd>
									<dd>
										<a>杂粮</a>
									</dd>
									<dd>
										<a>面粉</a>
									</dd>
									<dd>
										<a >薯类</a>
									</dd>
						</dl>
						<dl>
							<dt>
								<a>油</a>
							</dt>
									<dd>
										<a >茶油</a>
									</dd>
									<dd>
										<a >核桃油</a>
									</dd>
									<dd>
										<a >橄榄油</a>
									</dd>
									<dd>
										<a>芥花籽油</a>
									</dd>
						</dl>
						<dl>
							<dt>
								<a>水、软饮</a>
							</dt>
									<dd>
										<a >水</a>
									</dd>
									<dd>
										<a>软饮</a>
									</dd>
						</dl>
						<dl>
							<dt>
								<a >茶</a>
							</dt>
									<dd>
										<a >绿茶</a>
									</dd>
									<dd>
										<a>红茶</a>
									</dd>
									<dd>
										<a >乌龙茶</a>
									</dd>
									<dd>
										<a>白茶</a>
									</dd>
						</dl>
						<dl class="last">
							<dt>
								<a>亿家卡</a>
							</dt>
									<dd>
										<a >亿家卡</a>
									</dd>
									<dd>
										<a>    </a>
									</dd>
						</dl>
			</div>
			

		</div>
		<div class="span18 last">
			
			<div class="productImage">
					<a title="" style="outline-style: none; text-decoration: none;" id="zoom" href="http://image/r___________renleipic_01/bigPic1ea8f1c9-8b8e-4262-8ca9-690912434692.jpg" rel="gallery">
						<div class="zoomPad"><img style="opacity: 1;" title="" class="medium" src="${ pageContext.request.contextPath }/<s:property value="model.image"/>"><div style="display: block; top: 0px; left: 162px; width: 0px; height: 0px; position: absolute; border-width: 1px;" class="zoomPup"></div><div style="position: absolute; z-index: 5001; left: 312px; top: 0px; display: block;" class="zoomWindow"><div style="width: 368px;" class="zoomWrapper"><div style="width: 100%; position: absolute; display: none;" class="zoomWrapperTitle"></div><div style="width: 0%; height: 0px;" class="zoomWrapperImage"><img src="%E5%B0%9A%E9%83%BD%E6%AF%94%E6%8B%89%E5%A5%B3%E8%A3%852013%E5%A4%8F%E8%A3%85%E6%96%B0%E6%AC%BE%E8%95%BE%E4%B8%9D%E8%BF%9E%E8%A1%A3%E8%A3%99%20%E9%9F%A9%E7%89%88%E4%BF%AE%E8%BA%AB%E9%9B%AA%E7%BA%BA%E6%89%93%E5%BA%95%E8%A3%99%E5%AD%90%20%E6%98%A5%E6%AC%BE%20-%20Powered%20By%20Mango%20Team_files/6d53c211-2325-41ed-8696-d8fbceb1c199-large.jpg" style="position: absolute; border: 0px none; display: block; left: -432px; top: 0px;"></div></div></div><div style="visibility: hidden; top: 129.5px; left: 106px; position: absolute;" class="zoomPreload">Loading zoom</div></div>
					</a>
				
			</div>
			<div class="name"><s:property value="model.pname"/></div>
			<div class="sn">
				<div>编号:<s:property value="model.pid"/></div>
			</div>
			<div class="info">
				<dl>
					<dt>商城价:</dt>
					<dd>
						<strong>¥:<s:property value="model.shop_price"/>元</strong>
							参 考 价:
							<del>¥:<s:property value="model.market_price"/>元</del>
					</dd>
				</dl>
					<dl>
						<dt>促销:</dt>
						<dd>
								<a target="_blank" title="限时抢购 (2014-07-30 ~ 2015-01-01)">限时抢购</a>
						</dd>
					</dl>
					<dl>
						<dt>    </dt>
						<dd>
							<span>    </span>
						</dd>
					</dl>
			</div>
				<div class="action">
					
						<dl class="quantity">
							<dt>购买数量:</dt>
							<dd>
								<input id="quantity" name="quantity" value="1" maxlength="4" οnpaste="return false;" type="text">
								
							</dd>
							<dd>
								件
							</dd>
						</dl>
					<div class="buy">
							<input id="addCart" class="addCart" value="加入购物车" type="button">
				
					</div>
				</div>
			<div id="bar" class="bar">
				<ul>
						<li id="introductionTab">
							<a href="#introduction">商品介绍</a>
						</li>
						
				</ul>
			</div>
				
				<div id="introduction" name="introduction" class="introduction">
					<div class="title">
						<strong><s:property value="model.pdesc"/></strong>
					</div>
					<div>
						<img src="${pageContext.request.contextPath}/<s:property value="model.image"/>">
					</div>
				</div>
				
				
				
		</div>
	</div>
<div class="container footer">
	<div class="span24">
		<div class="footerAd">
					<img src="image\r___________renleipic_01/footer.jpg" alt="我们的优势" title="我们的优势" height="52" width="950">
</div>
</div>
	<div class="span24">
		<ul class="bottomNav">
					<li>
						<a href="#">关于我们</a>
						|
					</li>
					<li>
						<a href="#">联系我们</a>
						|
					</li>
					<li>
						<a href="#">诚聘英才</a>
						|
					</li>
					<li>
						<a href="#">法律声明</a>
						|
					</li>
					<li>
						<a>友情链接</a>
						|
					</li>
					<li>
						<a target="_blank">支付方式</a>
						|
					</li>
					<li>
						<a target="_blank">配送方式</a>
						|
					</li>
					<li>
						<a >SHOP++官网</a>
						|
					</li>
					<li>
						<a>SHOP++论坛</a>
						
					</li>
		</ul>
	</div>
	<div class="span24">
		<div class="copyright">Copyright © 2005-2015 网上商城 版权所有</div>
	</div>
</div>
</body>
</html>


  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
网上购物系统源码 主要功能模块 1,网上购物系统---商品功能   无限商品类别   可复制商品类别   可为商品设置属性配件(如不同颜色、尺码、主机配置),根据选取的不同配件自动生成价格   会员可发表商品评论   可在前台显示最新商品、热卖商品,推荐商品等   提供所见即所得的编辑器,方便地编辑丰富的商品信息呈现方式    2,网上购物系统---订单功能   订单具有“确认”、“到款”、“部分到款”、“发货”、“部分发货”、“退货”、“部分退货”、“归档”、“取消”状态,方便您控制购物流程的每个阶段   自定义订单打印格式   具有发货单、退货单、收款单、退款单等多种单据   方便快捷的多种条件查找订单    3,网上购物系统---会员功能  可向会员发送会刊、广告等邮件    4,网上购物系统---支付和配送功能   支持网银    5,网上购物系统---文章功能   无限文章分类   可通过模板标签的方式在前台引用任何文章 6,网上购物系统---管理功能   可添加多名管理员,具有不同的权限   内置数据库备份和回复功能    7,V-eShop网上购物系统---促销功能   可为商品设置赠品   自定义优惠券   自定义商品批发方案   商品可捆绑销售(如将洗面奶和洗发水这2种商品捆绑在一起销售)    8,网上购物系统-搜索引擎优化功能   自动提交google sitemap   静态优化,支持url rewrite,全站全静态页面 DIV布局,兼容性强。IE6.0 7.0 8.0都没问题 后台登陆用户名和吗都是51aspx
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值