spring-boot-sitemesh整合装饰器

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

项目启动访问路径 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>

Java代码 

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;  
    }  
}  

 

application.properties

Xml代码 

#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

转载于:https://my.oschina.net/leelance/blog/741419

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值