-
Create a table of primary categories :
CREATE TABLE `category` (
`cid` int(11) NOT NULL AUTO_INCREMENT,
`cname` varchar(255) DEFAULT NULL,
PRIMARY KEY (`cid`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
-
Build packages and corresponding classes :
* cn.itcast.shop.category
* action
* service
* CategoryService: business layer object
*dao
* CategoryDao: Persistence layer object
* vo
* Category: entity object
* Category.hbm.xml: Mapping file
-
Configure the Service and DAO :
* Inject sessionFactory in DAO
* Inject DAO in Service
-
Need to inject first-class service in IndexAction .
* Action-----Service------Dao
* Display the data of the first-level classification to the page :
* Store the data of the first-level classification into the session scope .
ActionContext.getContext().getSession().put("cList",cList);
Then read it iteratively in jsp and display
<s:iterator var="c" value="#session.cList">
<li><a href="xxx/xxx.html"><s:property value="#c.cname"></a></li>
</s:iterator>