jsp:param和meta來控制導航選中與否,頁面組合器sitemesh

來源:互聯網
上載者:User

標籤:頁面組合器sitemesh   jsp導覽功能表選中   html的meta的使用   

A.jsp

B.jsp

C.jsp

decorators.xml

其中A.jsp是某項功能具體的jsp,A包含B,C是預設範本包含B

註:需要瞭解sitemesh和decorators頁面組合器的主要知識http://www.cnblogs.com/luotaoyeah/p/3776879.html

需要下載sitemesh的jar包,不用組合器也可以實現

http://blog.csdn.net/liu251/article/details/2797488


decorators.xml中主要內容:裝飾器設定檔

    <!-- 預設範本 -->
    <decorator name="default" page="C.jsp">
        <pattern>/*</pattern>
    </decorator>


C.jsp主要內容:網頁組裝的模板

    <sitemesh:usePage id="thePage" />
    <%--菜單選擇 --%>
    <sitemesh:body/>
    <jsp:include page="/B.jsp">
        <jsp:param name="testmenu" value="${thePage.getProperty(\"meta.test\")}"/>
    </jsp:include>


B.jsp主要內容:菜單在這個jsp中來控制,公用頁面

<c:choose>
            <c:when test="${param.testmenu== ‘1‘}">
             
            </c:when>    

            <c:when test="${param.testmenu== ‘2‘}">
             
            </c:when>   

</c:choose>

A.jsp主要內容:獨立頁面

 <meta name="test" content="1" />


前提,每個類似A的獨立頁面都需要有meta,來規定自己的頁面需要位於在那個導航下。

C拿到A的meta為test的值,賦給B的jsp:param(name為testmunu),然後B根據${param.testmenu== ‘1‘}來判斷A頁面是要處於那個導覽功能表下,來進行導覽功能表的一些顏色等設定


如有不明白,繼續溝通

本文出自 “註冊” 部落格,請務必保留此出處http://6203973.blog.51cto.com/6193973/1615224

jsp:param和meta來控制導航選中與否,頁面組合器sitemesh

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.