decorators.xml

了解装饰器,先来了解下sitemesh

SiteMesh 是一个网页布局和修饰的框架,利用它可以将网页的内容和页面结构分离,以达到页面结构共享的目的,看下百度百科。

这东西就是统一装饰页面的,就像CSDN博客,上面都有统一的工具栏。

怎么用sitemesh呢,全都是配置

  这个写的很详细    http://www.cnblogs.com/luotaoyeah/p/3776879.html

最新版本:3.0.0-SNAPSHOT

① GitHub 地址:https://github.com/sitemesh/sitemesh3

② maven:

1 <dependency>
2   <groupId>org.sitemesh</groupId>
3   <artifactId>sitemesh</artifactId>
4   <version>3.0.0</version>
5 </dependency>

3 . 配置 Sitemesh 3 过滤器

在 web.xml 中添加 Sitemesh Filter: 

复制代码
 1 <web-app>
 2 
 3   ...
 4 
 5   <filter>
 6     <filter-name>sitemesh</filter-name>
 7     <filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
 8   </filter>
 9   <filter-mapping>
10     <filter-name>sitemesh</filter-name>
11     <url-pattern>/*</url-pattern>
12   </filter-mapping>
13   
14 </web-app>
复制代码

4 . 准备两个页面:demo.html 和 decorator.html

① demo.html - “被装饰的页面”,实际要呈现的内容页。

复制代码
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <title>内容页的标题</title>
5 </head>
6 <body>
7     内容页的body部分
8 </body>
9 </html>
复制代码

② decorator.html - “装饰页面”,所谓的“母版页”。

复制代码
 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <title>
 5     <sitemesh:write property='title' /> - ltcms
 6 </title>
 7 <sitemesh:write property='head' />
 8 </head>
 9 <body>
10     <header>header</header>
11     <hr />
12     demo.html的title将被填充到这儿:
13     <sitemesh:write property='title' /><br />
14     demo.html的body将被填充到这儿:
15     <sitemesh:write property='body' />
16     <hr />
17     <footer>footer</footer>
18 </body>
19 </html>
复制代码

5 . 添加 /WEB-INF/sitemesh3.xml

复制代码
1 <?xml version="1.0" encoding="UTF-8"?>
2 <sitemesh>
3     <!-- 指明满足“/*”的页面,将被“/WEB-INF/views/decorators/decorator.html”所装饰 -->
4     <mapping path="/*" decorator="/WEB-INF/views/decorators/decorator.html" />
5 
6     <!-- 指明满足“/exclude.jsp*”的页面,将被排除,不被装饰 -->
7     <mapping path="/exclude.jsp*" exclue="true" />
8 </sitemesh>
复制代码

6 . 运行效果

访问 demo.html 页面,实际效果如下:

7 . sitemesh3.xml 配置详解

复制代码
 1 <sitemesh>
 2     <!--默认情况下,
 3         sitemesh 只对 HTTP 响应头中 Content-Type 为 text/html 的类型进行拦截和装饰,
 4         我们可以添加更多的 mime 类型-->
 5   <mime-type>text/html</mime-type>
 6   <mime-type>application/vnd.wap.xhtml+xml</mime-type>
 7   <mime-type>application/xhtml+xml</mime-type>
 8   ...
 9   
10   <!-- 默认装饰器,当下面的路径都不匹配时,启用该装饰器进行装饰 -->
11   <mapping decorator="/default-decorator.html"/>
12   
13   <!-- 对不同的路径,启用不同的装饰器 -->
14   <mapping path="/admin/*" decorator="/another-decorator.html"/>
15   <mapping path="/*.special.jsp" decorator="/special-decorator.html"/>
16 
17   <!-- 对同一路径,启用多个装饰器 -->
18   <mapping>
19     <path>/articles/*</path>
20     <decorator>/decorators/article.html</decorator>
21     <decorator>/decorators/two-page-layout.html</decorator>
22     <decorator>/decorators/common.html</decorator>
23   </mapping>
24 
25   <!-- 排除,不进行装饰的路径 -->
26   <mapping path="/javadoc/*" exclue="true"/>
27   <mapping path="/brochures/*" exclue="true"/>
28   
29   <!-- 自定义 tag 规则 -->
30   <content-processor>
31     <tag-rule-bundle class="com.something.CssCompressingBundle" />
32     <tag-rule-bundle class="com.something.LinkRewritingBundle"/>
33   </content-processor>
34   ...
35 
36 </sitemesh>
复制代码

8 . 自定义 tag 规则

Sitemesh 3 默认只提供了 body,title,head 等 tag 类型,我们可以通过实现 TagRuleBundle 扩展自定义的 tag 规则:

复制代码
 1 public class MyTagRuleBundle implements TagRuleBundle {
 2     @Override
 3     public void install(State defaultState, ContentProperty contentProperty,
 4             SiteMeshContext siteMeshContext) {
 5         defaultState.addRule("myHeader", new ExportTagToContentRule(contentProperty.getChild("myHeader"), false));
 6         
 7     }
 8     
 9     @Override
10     public void cleanUp(State defaultState, ContentProperty contentProperty,
11             SiteMeshContext siteMeshContext) {
12     }
13 }
复制代码

最后在 sitemesh3.xml 中配置即可:

1 <content-processor>
2     <tag-rule-bundle class="com.lt.common.ext.sitemesh3.MyTagRuleBundle" />
3 </content-processor>
然后就是关于具体decorators用法了,
<?xml version="1.0" encoding="UTF-8"?>

<decorators defaultdir="/decorators">
    <!-- 在excludes元素下指定的页面将不会由SiteMesh来装饰 不配置的话,一些ajax异步,是不能实现的-->
    <excludes>
        <pattern>/exclude.jsp</pattern>
        <pattern>/exclude/*</pattern>
        <pattern>/css/*</pattern>
        <pattern>/js/*</pattern>
        <pattern>/images/*</pattern>
        <pattern>/decorators/*</pattern>
        <pattern>/admin/login.action</pattern>
        <pattern>/index/user/user!regist.action</pattern>
        <pattern>/index/classify/content!choseFolder.action</pattern>
        <pattern>/index/store/folder!choseFolder.action</pattern>
       
       
    </excludes>

    <!-- 创建一个名为main的装饰器,该装饰器页面为main.jsp,
        用于装饰pattern指定的URL的所有页面-->
    <decorator name="admin" page="admin/admin.jsp">
        <pattern>/admin/welcome.action</pattern>
        <pattern>/admin/pubinfo/*</pattern>
        <pattern>/admin/classify/*</pattern>
        <pattern>/admin/user/*</pattern>
        <pattern>/admin/promotion/promotion.action</pattern>
        <pattern>/admin/region/region.action</pattern>
        <pattern>/admin/promotion/promotion.action</pattern>
    </decorator>
   
    <decorator name="admin-input" page="admin/input.jsp">
        <pattern>/admin/user/*!input.action</pattern>
        <pattern>/admin/classify/classify!input.action</pattern>
        <pattern>/admin/classify/classify!parent.action</pattern>
        <pattern>/admin/classify/classify!clsForm.action</pattern>
        <pattern>/admin/pubinfo/*!input.action</pattern>
        <pattern>/admin/region/region!input.action</pattern>
        <pattern>/admin/promotion/promotion!input.action</pattern>
       
    </decorator>
   
    <decorator name="index" page="index/index.jsp">
        <!--pattern>/index/classify/index*</pattern-->
        <pattern>/index/index.action</pattern>
    </decorator>
   
    <decorator name="city" page="index/city.jsp">
        <pattern>/index/area/*</pattern>
    </decorator>
</decorators>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
C:\Users\TXN>CD C:// C:\>Python "C:\Program Files (x86)\Intel\openvino_2021.4.752\deployment_tools\open_model_zoo\demos\human_pose_estimation_demo\python\human_pose_estimation_demo.py" -at openpose -d CPU -i 0 -m D:\model\fall_detection_zpp\intel\human-pose-estimation-0001\FP16\human-pose-estimation-0001.xml [ INFO ] Initializing Inference Engine... [ INFO ] Loading network... [ INFO ] Reading network from IR... Traceback (most recent call last): File "C:\Program Files (x86)\Intel\openvino_2021.4.752\deployment_tools\open_model_zoo\demos\human_pose_estimation_demo\python\human_pose_estimation_demo.py", line 283, in <module> sys.exit(main() or 0) File "C:\Program Files (x86)\Intel\openvino_2021.4.752\deployment_tools\open_model_zoo\demos\human_pose_estimation_demo\python\human_pose_estimation_demo.py", line 184, in main model = get_model(ie, args, frame.shape[1] / frame.shape[0]) File "C:\Program Files (x86)\Intel\openvino_2021.4.752\deployment_tools\open_model_zoo\demos\human_pose_estimation_demo\python\human_pose_estimation_demo.py", line 111, in get_model prob_threshold=args.prob_threshold) File "C:\Program Files (x86)\Intel\openvino_2021.4.752\deployment_tools\open_model_zoo\demos\common\python\models\open_pose.py", line 62, in __init__ strides=(1, 1), name=self.pooled_heatmaps_blob_name) File "C:\Users\TXN\AppData\Local\Programs\Python\Python37\lib\site-packages\ngraph\utils\decorators.py", line 22, in wrapper node = node_factory_function(*args, **kwargs) TypeError: max_pool() missing 1 required positional argument: 'dilations'
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值