zoukankan      html  css  js  c++  java
  • spring boot 配置 beetl 视图解析器

    package org.whm.core;
    
    import org.beetl.core.resource.ClasspathResourceLoader;
    import org.beetl.ext.spring.BeetlGroupUtilConfiguration;
    import org.beetl.ext.spring.BeetlSpringViewResolver;
    import org.springframework.beans.factory.annotation.Qualifier;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.ComponentScan;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.core.io.DefaultResourceLoader;
    import org.springframework.core.io.support.ResourcePatternResolver;
    import org.springframework.core.io.support.ResourcePatternUtils;
    
    @Configuration
    @ComponentScan(basePackages = { "org.whm" })
    @EnableAutoConfiguration
    public class AppConfig {
    
        // 主方法
        public static void main(String[] argss) {
            String[] args = { "--spring.config.location=classpath:config/app.yml" };
            SpringApplication.run(AppConfig.class, args);
        }
    
        @Bean(initMethod = "init", name = "beetlConfig")
        public BeetlGroupUtilConfiguration getBeetlGroupUtilConfiguration() {
            BeetlGroupUtilConfiguration beetlGroupUtilConfiguration = new BeetlGroupUtilConfiguration();
            ClasspathResourceLoader classpathResourceLoader = new ClasspathResourceLoader();
            beetlGroupUtilConfiguration.setResourceLoader(classpathResourceLoader);
            
            //设置 beetl.properties 路径。。。。。
            ResourcePatternResolver resouce = ResourcePatternUtils.getResourcePatternResolver(new DefaultResourceLoader());
            beetlGroupUtilConfiguration.setConfigFileResource(resouce.getResource("classpath:config/beetl.properties"));
            
            
            return beetlGroupUtilConfiguration;
        }
    
        @Bean(name = "beetlViewResolver")
        public BeetlSpringViewResolver getBeetlSpringViewResolver(
                @Qualifier("beetlConfig") BeetlGroupUtilConfiguration beetlGroupUtilConfiguration) {
            BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
            beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
            //不启用 springMvc 的 前缀。。使用 beetl自带 的 RESOURCE.root
            // beetlSpringViewResolver.setPrefix("webapp/views/");
            beetlSpringViewResolver.setSuffix(".html");
            beetlSpringViewResolver.setOrder(0);
            beetlSpringViewResolver.setConfig(beetlGroupUtilConfiguration);
            return beetlSpringViewResolver;
        }
    }
  • 相关阅读:
    如何将javaweb项目部署到阿里云服务器上
    解决ueditor配置文件第一行报错及乱码问题
    解决web.xml中<async-supported>true</async-supported>报错问题
    解决建完Maven项目没有main文件夹问题
    CentOS常用命令之搜索文件
    CentOS常用命令之创建删除剪切链接
    Jupyter notebook: TypeError: __init__() got an unexpected keyword argument 'io_loop 问题
    编译分布式并行版caffe(Open MPI)教程
    树状数组
    马拉车算法
  • 原文地址:https://www.cnblogs.com/whm-blog/p/7259487.html
Copyright © 2011-2022 走看看