How do I integrate Sitemesh 3 with Spring MVC 3?

前端 未结 3 1490
傲寒
傲寒 2021-01-13 23:56

I am trying to use Sitemesh 3 to control the decoration of JSP output from a Spring MVC application.

When I hit the application it seems that Sitemesh is making a re

相关标签:
3条回答
  • 2021-01-14 00:26

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

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-14 00:36

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

    0 讨论(0)
提交回复
热议问题