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

      

  • 相关阅读:
    LeetCode【21】 Merge Two Sorted Lists
    LeetCode【2】Add two numbers
    LeetCode【125】Valid Palindrome
    LeetCode【9】Palindrome Number
    LeetCode【20】Valid Parentheses
    LeetCode【1】Two Sum
    LeetCode【8】string to integer(atoi)
    LeetCode【168】Excel Sheet Column Title
    lambda表达式
    UML类图
  • 原文地址:https://www.cnblogs.com/ZSG-DoBestMe/p/5138751.html
Copyright © 2011-2022 走看看