zoukankan      html  css  js  c++  java
  • thymeleaf控制view的返回格式

    package com.ailk.dd1.jike.web.config;
    
    import nz.net.ultraq.thymeleaf.LayoutDialect;
    
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.thymeleaf.spring4.SpringTemplateEngine;
    import org.thymeleaf.spring4.view.ThymeleafViewResolver;
    import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
    //import com.ailk.retail.web.thymeleaf.expression.SmallFunctionHelper;
    
    @Configuration
    public class ViewConfiguration {
    
        @Bean
        public ClassLoaderTemplateResolver templateResolver() {
            ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
            templateResolver.setTemplateMode("HTML5");
            templateResolver.setPrefix("pages/");
            templateResolver.setSuffix(".html");
            templateResolver.setCharacterEncoding("utf-8");
            templateResolver.setOrder(1);
    
            templateResolver.setCacheable(false);
            return templateResolver;
        }
    
        @Bean
        public SpringTemplateEngine templateEngine() {
            SpringTemplateEngine engine = new SpringTemplateEngine();
            engine.setTemplateResolver(templateResolver());
    //        engine.addDialect(new DataTablesDialect());
            engine.addDialect(new LayoutDialect());
            return engine;
        }
    
        @Bean
        public ThymeleafViewResolver thymeleafViewResolver() {
            ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
            viewResolver.setTemplateEngine(templateEngine());
            viewResolver.setCharacterEncoding("utf-8");
    //        SmallFunctionHelper.addSmallFunctionTag(viewResolver);
            return viewResolver;
        }
    
    }
    

      

  • 相关阅读:
    spring boot中 使用http请求
    spring boot 多层级mapper
    spring boot 使用拦截器,注解 实现 权限过滤
    spring boot 集成mybatis报错
    spring boot 使用拦截器 实现 用户登录拦截
    mac eclipse 删除不用的workspace
    maven+eclipse+mac+tomcat 多模块发布
    启动spring boot 异常
    安装 redis [standlone模式]
    quartz项目中的运用
  • 原文地址:https://www.cnblogs.com/ZSG-DoBestMe/p/5138751.html
Copyright © 2011-2022 走看看