---
title: "spring-boot集成sitemesh装饰器"
author: "lihao312"
date: "2016-09-02T09:41:16Z"
tags: ["easyui", "sitemesh", "spring-mvc"]
categories: ["编程语言"]
slug: "spring-boot-sitemesh"
draft: false
lastmod: "2016-09-02T09:46:04Z"
id: 2322211
url: "https://lihao312.iteye.com/blog/2322211"
---

# spring-boot-sitemesh, 依赖spring-boot-parent

- [spring-boot](http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/)
- [EasyUi](http://www.jeasyui.net/)
- [SiteMesh](http://wiki.sitemesh.org/wiki/display/sitemesh3/Getting+Started+with+SiteMesh+3)

项目启动访问路径 http://localhost/admin/index

```
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.5.RELEASE</version>
</parent>
<dependency>
    <groupId>org.sitemesh</groupId>
    <artifactId>sitemesh</artifactId>
    <version>3.0.1</version>
</dependency>
```

```
public class WebSiteMeshFilter extends ConfigurableSiteMeshFilter{

    @Override
    protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
        builder.addDecoratorPath("/admin/*", "/admin/index")
               .addExcludedPath("/admin/index")
               .addExcludedPath("/plugin/*");
    }
}

@Configuration
public class WebConfig extends WebMvcConfigurerAdapter{
    /**
     * 装饰器
     * @return
     * 2016年8月27日下午12:37:20
     */
    @Bean
    public FilterRegistrationBean siteMeshFilter(){
        FilterRegistrationBean fitler = new FilterRegistrationBean();
        WebSiteMeshFilter siteMeshFilter = new WebSiteMeshFilter();
        fitler.setFilter(siteMeshFilter);
        return fitler;
    }
}
```

### [](https://github.com/leelance/spring-boot-all/tree/master/spring-boot-sitemesh#applicationproperties)application.properties

```
#Server
server.port=80
server.jsp-servlet.class-name=org.apache.jasper.servlet.JspServlet

security.basic.enabled=false
management.security.enabled=false

#MVC
spring.mvc.view.prefix=/WEB-INF/views/
spring.resources.static-locations=classpath:/static/

security.basic.enabled=false
management.security.enabled=false

#LOG
logging.config=classpath:log4j2.xml
```

 

[完整项目路径](https://github.com/leelance/spring-boot-all/tree/master/spring-boot-sitemesh "spring-boot-sitemesh")

https://github.com/leelance/spring-boot-all/tree/master/spring-boot-sitemesh