Sitemesh不装饰返回的视图 [英] Sitemesh does not decorate returned views

查看:89
本文介绍了Sitemesh不装饰返回的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立一个简单的装饰有Sitemesh的页面,但现在遇到了麻烦.

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

首先,我的设置是

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

这里没什么特别的

#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>

没什么特别的

当我调用应用程序的索引时,它会被修饰. 当我单击调用返回视图的控制器的链接时,返回的视图不会得到修饰.实际上,这目前仅适用于欢迎文件. 我尝试了不同的装饰器模式,结果相同或不同:D

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?

谢谢!

推荐答案

对于sitemesh视图装饰,它将主"模板视为默认模板.因此,如果您没有在要装饰的JSP中指定任何模板,那么它将把decoration.xml中的定义作为主要内容.

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.

如果您的应用程序中只有一个模板(机会很少),则将装饰器名称从basicLayout重命名为main.

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

如果没有,则可以在JSP中使用以指定要使用的装饰器.

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

这篇关于Sitemesh不装饰返回的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆