Online Book Mall 2--category module

Source: Internet
Author: User

Sql

CREATE TABLE ' t_category ' (  ' cid ' char (+) NOT NULL,  ' CNAME ' varchar () default NULL,  ' pid ' char (+) ' Default ' NULL,  ' desc ' varchar (+) DEFAULT null,  ' auto_increment ' int (one) not NULL,  PRIMARY KEY (' CID '),  UNIQUE KEY ' cname ' (' cname '),  Key ' Fk_t_category_t_category ' (' pid '),  key ' by ' (' by ') ', '  CONSTRAINT ' fk_t_category_t_category ' FOREIGN KEY (' pid ') REFERENCES ' t_category ' (' CID ')) Engine=innodb auto_increment=48 DEFAULT Charset=utf8;

  

Dao

Public list<category> FindAll () throws SQLException {/* * 1. Query out all first-level classifications */string sql = "SELECT * FROM T_category wher E PID is a null order by "; list<map<string,object>> maplist = qr.query (sql, New Maplisthandler ()); list<category> parents = tocategorylist (maplist);/* * 2. Loops through all of the first-level classifications, loading its level two category  */for (category parent:parents) {//querying out all subcategories of the current parent category list<category> children = Findbyparent (Parent.getcid ());//set to parent category Parent.setchildren (children);} return parents;}

  

left.jsp

Q6menubar Component display Accordion drop-down menu

<script language= "javascript" >$ (function () {.... <c:foreach items= "${parents}" var= "parent" >  <c: ForEach items= "${parent.children}" var= "Child" >bar.add ("${parent.cname}", "${child.cname}", "/goods/bookservlet ? Method=findbycategory&cid=${child.cid} "," body ");  </c:foreach></c:foreach>});</script>

  

Online Book Mall 2--category module

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.