问题
I would like to have all the requests decorated except my welcome page. This is the default page I display when only my application context is in the url with no other path elements.
http://hostname:8080/MyApp/ -> This should not be decorated. This should show my Welcome page. How do I exclude this?
http://hostname:8080/MyApp/user -> This gets decorated now with below config
I have the following decorators.xml.
<!-- Any urls that are excluded will never be decorated by Sitemesh -->
<excludes>
<pattern>/exclude/*</pattern>
</excludes>
<decorator name="main" page="main.jsp">
<pattern>/*</pattern>
</decorator>
I am using Spring MVC where the dispatch servlet is configured to take all the input requests. and I have a controller to display my Welcome page for request mapping "/".
<servlet-mapping>
<servlet-name>MyApp</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
回答1:
I found a way to do it myself. In my welcome.jsp I added a meta tag as shown below and in the decorators.xml you add a decorator for welcome.
<head>
<meta name="decorator" content="welcome">
</head>
decorators.xml
<decorator name="main" page="main.jsp">
<pattern>/*</pattern>
</decorator>
<decorator name="welcome" page="welcome.jsp"/>
来源:https://stackoverflow.com/questions/7153167/sitemesh-spring-3-0-exclude-pattern