Online mall 4 -- query of the second-level category on the homepage; 4 -- second-level category

Source: Internet
Author: User

Online mall 4 -- query of the second-level category on the homepage; 4 -- second-level category

 

1. Create a table

Create table 'categorysecond' ('csid' int (11) not null AUTO_INCREMENT, 'csname' varchar (255) default null, 'cid' int (11) default null, primary key ('csid '), KEY 'fk936fcaf21db1fd15' ('cid'), CONSTRAINT 'fk936fcaf21db1fd15 'foreign key ('cid') REFERENCES 'category' ('cid ')) ENGINE = InnoDB AUTO_INCREMENT = 37 default charset = utf8; insert into 'categorysecond' VALUES ('1', 'trendy Women's upgrade', '1 '); insert into 'categorysecond' VALUES ('2', 'Winter Day', '1'); insert into 'categorysecond' VALUES ('3', 'woolen overcoats ', '1'); insert into 'categorysecond' VALUES ('4', 'warm url', '1'); insert into 'categorysecond' VALUES ('5 ', 'selected men's wear ', '1'); insert into 'categorysecond' VALUES ('6', 'Winter coats', '1 '); insert into 'categorysecond' VALUES ('7', 'undercoats ', '1'); insert into 'categorysecond' VALUES ('9', 'Women shoes', '2 '); insert into 'categorysecond' VALUES ('10', 'Boots ', '2'); insert into 'categorysecond' VALUES ('11', 'Men's shoes', '2 '); insert into 'categorysecond' VALUES ('12', 'female bundle ', '2'); insert into 'categorysecond' VALUES ('13', 'male bundle', '2 '); insert into 'categorysecond' VALUES ('14', 'apparel accessories ', '2'); insert into 'categorysecond' VALUES ('15', 'sneakers ', '3'); insert into 'categorysecond' VALUES ('16', 'track', '3'); insert into 'categorysecond' VALUES ('17 ', 'outdoor sports ', '3'); insert into 'categorysecond' VALUES ('18', 'fitness equipment', '3 '); insert into 'categorysecond' VALUES ('19', 'cycling equiptment ', '3'); insert into 'categorysecond' VALUES ('20', 'Jewelry ', '4'); insert into 'categorysecond' VALUES ('21', 'fashion jewelry ', '4'); insert into 'categorysecond' VALUES ('22 ', 'Quality watch ', '4'); insert into 'categorysecond' VALUES ('23', 'glasses accessory', '4 '); insert into 'categorysecond' VALUES ('24', 'cell phone ', '5'); insert into 'categorysecond' VALUES ('25', 'flat', '5 '); insert into 'categorysecond' VALUES ('26', 'computer ', '5'); insert into 'categorysecond' VALUES ('27', 'camera', '5 '); insert into 'categorysecond' VALUES ('28', 'household appliances ', '6'); insert into 'categorysecond' VALUES ('29', 'kitchen appliances ', '6'); insert into 'categorysecond' VALUES ('30', 'household Electric Appliance ', '6'); insert into 'categorysecond' VALUES ('31 ', 'household appliances ', '6'); insert into 'categorysecond' VALUES ('32', 'Office consumables', '6 '); insert into 'categorysecond' VALUES ('33', 'skin beautifier ', '7'); insert into 'categorysecond' VALUES ('34', 'powerful maintain ', '7'); insert into 'categorysecond' VALUES ('35', 'value-added makeup ', '7'); insert into 'categorysecond' VALUES ('36 ', 'seasonal maintenance ', '7 ');

 

2. Level 2 classification under Level 1 Classification

<s:iterator var="c" value="#session.cList"><dl><dt><a href="${pageContext.request.contextPath}/product_findByCid.action?cid=<s:property value="#c.cid"/>&page=1"><s:property value="#c.cname"/></a></dt><s:iterator var="cs" value="#c.categorySeconds"><dd><a href="${ pageContext.request.contextPath }/product_findByCsid.action?csid=<s:property value="#cs.csid"/>&page=1"><s:property value="#cs.csname"/></a></dd></s:iterator></dl></s:iterator>

 

Category. hbm. xml

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE hibernate-mapping PUBLIC     "-//Hibernate/Hibernate Mapping DTD 3.0//EN"    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

  

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.