1, in the index.jsp to pass the Product ID, add the contents of the href in a tag, href= "${pagecontext.request.contextpath}/product_findbypid.action?pid=<s :p roperty 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"/> "> "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 ();p ublic void Setproductservice (Productservice productservice) {This.productservice = Productservice;} Public String Findbypid () {Product = Productservice.findbypid (Product.getpid ()); return "Findbypid";} Public product Getmodel () {return Product;}}
3, the method of adding findbypid in Productservice.java
/** * According to the PID query product information * @param PID * @return */public product findbypid (Integer pid) {return productdao.findbypid (PID);}
4. Join in Productdao.javaMethods of Findbypid
/** * Search items by ID * @param pid * @return */public product findbypid (Integer pid) {return this.gethibernatetemplate (). Get (Prod Uct.class, PID);}
5. Struts.xml Configuration
<!--item--- <action name= "product_*" class= "productaction" method= "{1}" > <result name= " Findbypid ">/WEB-INF/jsp/product.jsp</result> </action>
6, ApplicationContext
<!--item 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 ">
14. Home Click Products Show Product Details