Dao层接口
import java.util.List;
import com.zxg.vo.ItemType;
//${param.name }适用于get和post请求
public interface IItemTypeDao {
/** 获取所有对象*/
List<ItemType> findAll();
}
二级分类展开收缩效果
<div id="itemType">
<p>商品分类</p>
<dl>
<c:forEach var="big" items="${itemTypes}">
<!-- 取得当前大类赋给big -->
<c:if test="${big.pid eq 0}">
<dt οnclick="display('span_${big.id }')">${big.name }</dt>
</c:if>
<!-- 取得所有类的pid=当前大类的id,即小类,然后把所有子类装在span中
用${big.id }加以区别,id是唯一的,此处可以用div,span,p标签控制隐藏显示,
即展开收缩,但p标签有多余的空格,不是很好
-->
<span id="span_${big.id }">
<c:forEach var="small" items="${itemTypes}">
<c:if test="${small.pid eq big.id}">
<!-- 这里不用传页数,默认为第一页 -->
<dd><a href="IndexServlet?smallType=${small.id }">${small.name }</a></dd>
</c:if>
</c:forEach>
</span>
</c:forEach>
</dl>
</div>
展开收缩效果脚本
function display(id){
//当不显示时就显示,动态的只能用document对象获取id
if($(id).style.display == "none"){
$(id).style.display = "";
}else{
$(id).style.display = "none"
}
}
二级分类用数据字典设计,如