我正在构建Spring 4 MVC应用程序。我已经将sitemesh与我的项目集成了......但是,我正在尝试准备XML免费配置 - 我没有web.xml文件,当然我想把我的装饰者的烦恼转移到Java Config类中。是否可以这样配置我的装饰器?
答案 0 :(得分:4)
我不确定sitemesh v2。我查看了他们的文档,但无法找到与Java配置相关的任何内容。如果更新到v3,则可以继承ConfigurableSiteMeshFilter并覆盖applyCustomConfiguration方法。更多信息可以在http://wiki.sitemesh.org/wiki/display/sitemesh3/Configuring+SiteMesh+3找到。以下提供的链接示例
public class MySiteMeshFilter extends ConfigurableSiteMeshFilter {
@Override
protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
// Map default decorator. This shall be applied to all paths if no other paths match.
builder.addDecoratorPath("/*", "/default-decorator.html")
// Map decorators to path patterns.
.addDecoratorPath("/admin/*", "/another-decorator.html")
.addDecoratorPath("/*.special.jsp", "/special-decorator.html")
// Map multiple decorators to the a single path.
.addDecoratorPaths("/articles/*", "/decorators/article.html",
"/decoratos/two-page-layout.html",
"/decorators/common.html")
// Exclude path from decoration.
.addExcludedPath("/javadoc/*")
.addExcludedPath("/brochures/*");
}
}