学习spring boot 小记之 sitemesh3 整合

原创
2016/09/01 11:36
阅读数 1.2K
public class SiteMeshFilter extends ConfigurableSiteMeshFilter {

   @Override
   protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
      builder.addDecoratorPath("/*","/WEB-INF/jsp/login.jsp");
   }


}
@Configuration
public class WebConfig {

    @Bean(name="sitemesh3")
    SiteMeshFilter siteMeshFilter(){
        return new SiteMeshFilter();
    }

    @Bean
    public FilterRegistrationBean filterRegistrationBean(@Qualifier("sitemesh3") SiteMeshFilter siteMeshFilter){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(siteMeshFilter);
        filterRegistrationBean.setEnabled(true);
        filterRegistrationBean.addUrlPatterns("/*");
        return filterRegistrationBean;
    }
}

spring boot 提供3个ServletRegistrationBean,FilterRegistrationBean,ServletListenerRegistrationBean来细化控制。FilterRegistrationBean 注册sitemesh3 filter 进行配置。 

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部