siteMesh + Spring 3.0 + Exclude pattern

一个人想着一个人 提交于 2019-12-08 04:32:36

问题


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

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