sitemesh and spring MVC decorator pattern problems

后端 未结 4 1330
借酒劲吻你
借酒劲吻你 2021-01-03 13:15

I have sitemesh with spring working, this is the configuration: decorator.xml




        
4条回答
  •  渐次进展
    2021-01-03 13:37

    The problem is that SiteMesh uses Request.getServletPath() which in your spring mvc application will return "/spring" for everything. I found this by implementing the com.opensymphony.module.sitemesh.DecoratorMapper interface and using it in place of the normal ConfigDecoratorMapper. Then I was able to inspect the various arguments used to map decorators to requests. Unfortunately, I think this leaves you with the only option being to use the *.html suffix in the DispatcherServelet mapping or some variant thereof.

    Another option would be to configure a PageDecoratorMapper and use this tag in your original undecorated page to specify which layout to use:

      
    

    Although then you void the benefits of url mappings.

提交回复
热议问题