All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fastchar.extend.thymeleaf.FastTemplateResolver Maven / Gradle / Ivy

package com.fastchar.extend.thymeleaf;

import com.fastchar.core.FastChar;
import org.thymeleaf.templatemode.TemplateMode;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;

import javax.servlet.ServletContext;

public class FastTemplateResolver extends ServletContextTemplateResolver {

    public FastTemplateResolver(ServletContext servletContext) {
        super(servletContext);
        initConfig();
    }

    private void initConfig() {
        setPrefix("/");
        setCacheable(true);
        if (FastChar.getConstant().isDebug()) {
            setCacheTTLMs(0L);
        } else {
            setCacheTTLMs(3600000L);//缓存一个小时
        }
        setCharacterEncoding(FastChar.getConstant().getEncoding());
        setTemplateMode(TemplateMode.HTML);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy