Springboot Freemarker配置全局变量配置类



package com.xhd.read.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Slf4j
@Configuration
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FreeMarkerConfig {
@Autowired
private freemarker.template.Configuration configuration;

@Value("${system.ctx}")
private String ctx;

@Value("${system.spath}")
private String spath;



@PostConstruct
public void setConfigure() throws Exception {

configuration.setSharedVariable("CPATH", ctx);
configuration.setSharedVariable("SPATH", spath);

}

}
 
---------------------


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM