我之前是做asp.net的,碰到被多個頁面都使用的類似組件后,就想著采用ascx(用戶自定義組件)來解決,那做java我也想用這種方案。
我要做的效果如下:

實現方案:tag方式(自定義標簽)
1. 首先定義自己的tag

1 <%@ tag body-content="scrjsp/jstl/fmt" recommend.tag2. 使用自定義的標簽
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
<t:recommend table="" idfield=""></t:recommend>
3.recommenttype 的數據源:使用頁面對應的Controller中的handleRequest
1 HashMap<String,String> recommentType = new HashMap<String,String>();2 recommentType.put("1", "首頁"); 3 recommentType.put("2", "其他"); 4 request.setAttribute(Constants.RECOMMENT_TYPE, recommentType);handleRequest附用到的樣式
1 #divRecomment{2 margin-left:12px;3 }4 #divRecomment select{5 width:200px;6 height:38px;7 border:1px solid #cccccc;8 }main.CSS
新聞熱點
疑難解答