How do I integrate Sitemesh 3 with Spring MVC 3?

陌路散爱 提交于 2019-12-01 06:34:13

Since no one has posted actual content, here you go:

in pom.xml add:

<dependency>
    <groupId>org.sitemesh</groupId>
    <artifactId>sitemesh</artifactId>
    <version>3.0.0</version>
</dependency>

in WEB-INF/web.xml † add:

<filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

in WEB-INF/sitemesh3.xml add:

<sitemesh>
    <mapping path="/*" decorator="/WEB-INF/decorator1.jsp"/>
</sitemesh>

in WEB-INF/decorator1.jsp add:

<html>
    <head>
    ...
    </head>
    <body>
        <sitemesh:write property='body'/>
    </body>
</html>

† put this below your Spring Security Filter Chain if using Spring Security.

Here is another blog that shows the integration between Sitemesh 3 and Spring MVC

In my case, I used this little tutorial to make it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!