Sitemesh does not decorate returned views

落花浮王杯 提交于 2019-12-11 04:06:08

问题


I have tried to set up a simple sitemesh decorated page, but am running into a wall now.

First, my setup:

#decorators.xml
<?xml version="1.0" encoding="UTF-8"?>
<decorators>
    <decorator name="basicLayout" page="/WEB-INF/views/layout.jsp">
        <pattern>*</pattern>
    </decorator>
</decorators>

Nothing special here

#web.xml
<filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<filter-mapping>
   <filter-name>sitemesh</filter-name>
   <url-pattern>*.jsp</url-pattern>
</filter-mapping>

Nothing special there

When I call the index of the application, it gets decorated. When I click a link calling a controller that returns a view, the returned view does not get decorated. Actually, this only works for the welcome-file at the moment. I tried different decorator pattern, the result is either the same or an excepton :D

Can someone give me a hint on this?

Thanks!


回答1:


for sitemesh view decoration it considers "main" template as default. so if you don't specify any template in your JSP (to be decorated) then it takes defination as main from decorator.xml.

if you are going to have only one template in your application (very less chances) then rename decorator name from basicLayout to main.

if not then you can use in JSP to specify which decorator to be used.



来源:https://stackoverflow.com/questions/11724791/sitemesh-does-not-decorate-returned-views

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