readAppfuse-4-Sitemesh使用

★      作用:sitemesh应用Decorator模式,用filter截取request和response,把页面组件

         head,content,banner结合为一个完整的视图[引用]。

★     appfuse的使用:

(1) 在WEB-INF/web.xml中的过滤器的定义

    <filter></filter>

        <filter-name></filter-name>sitemesh

        <filter-class></filter-class>

 com.opensymphony.module.sitemesh.filter.PageFilter
 

   
    <filter-mapping></filter-mapping>
        <filter-name></filter-name>sitemesh
        <!---->
        <url-pattern></url-pattern>/*
        <!---->
        <dispatcher></dispatcher>REQUEST
        <dispatcher></dispatcher>FORWARD
 

(2)common/taglibs.jsp中的标签申明,只是命名说明,具体调用时,应用会在WEB-INF/lib中的对应

的sitemesh-x.x.jar中定位。

 <!---->

<!---->

(3)WEB-INF/sitemesh.xml文件(可选),进行sitemesh配置

<sitemesh></sitemesh>
         <property name="decorators-file" value="/WEB-INF/decorators.xml"></property>

         <excludes file="${decorators-file}"></excludes>

         <page-parsers></page-parsers>

        <parser default="true" font=""></parser>

           class="com.opensymphony.module.sitemesh.parser.FastPageParser"/>

        <parser content-type="text/html"></parser>             class="com.opensymphony.module.sitemesh.parser.FastPageParser"/>

        <parser content-type="text/html;charset=ISO-8859-1"></parser>             class="com.opensymphony.module.sitemesh.parser.FastPageParser"/>

        <!---->

        <!---->

        <parser content-type="text/plain"></parser>             class="com.opensymphony.module.sitemesh.parser.FastPageParser"/>
   

    <decorator-mappers></decorator-mappers>

        <mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper"></mapper>

           

       

   


(4)WEB-INF/decorators.xml文件,指定具体的装饰页。

<decorators defaultdir="/decorators"></decorators>
             <excludes></excludes>

                 <pattern></pattern> /demos/*

                 <pattern></pattern> /resources/*

            

             <decorator name="default" page="default.jsp"></decorator>

                     <pattern></pattern> /*

            

 

 (5)装饰页/decorators/default.jsp的主要内容。


       

        


         <!---->


        <!---->中间-->


       

        <!---->


        <script type="text/javascript" <="" p="">

src="<c:url value="/scripts/helptip.js">"></script>


        <link media="all" type="text/css" rel="stylesheet" p="">

 href="<c:url value="/styles/default.css"></c:url>" />

        <link media="all" type="text/css" rel="stylesheet" p="">

 href="<c:url value="/styles/helptip.css"></c:url>" />


        <link media="print" type="text/css" rel="stylesheet" p="">

 href="<c:url value="/styles/print.css"></c:url>" />    

        <script type="text/javascript" <="" p="">

 src="<c:url value="/scripts/global.js">"></script>

        <link media="all" type="text/css" rel="stylesheet" p="">

 href="<c:url value="/styles/menuExpandable.css"></c:url>" />

        <script type="text/javascript" <="" p="">

 src="<c:url value="/scripts/menuExpandable.js">"></script>
 <!---->

 <decorator:head></decorator:head>
   

<!---->

可以添加一个缺省值-->

>

   

 

     

 

            <c:import url="/common/header.jsp"></c:import>
      


            <c:import url="/WEB-INF/pages/menu.jsp"></c:import>

 

     


           

<decorator:getproperty property="page.heading"></decorator:getproperty>


            <!---->
            <!---->
            <decorator:body></decorator:body>
       

 

       


            <c:import url="/common/footer.jsp"></c:import>
       

 

     


 


你可能感兴趣的:(C++,c,jsp,css,C#)