spring boot 如何创建和使用freemaker自定义标签

由于spring boot 简化了配置文件的,所以之前在配置文件中实现自定义freemaker标签,统一通过Java类实现。

之前spring MVC 的实现步骤:



   
   
      
         
         
            
         
      
   

那么spring boot 中如何实现,具体实现如下:

创建 FreemarkerConfig ,
@Component
public class FreemarkerConfig {

  @Autowired
  private Configuration configuration;

  @PostConstruct
  public void setSharedVariable() {
// 创建自定义标签对象
    configuration.setSharedVariable("shiro", new ShiroTags());
  }

}

通过上述方法可以实现引入freemaker 自定义标签

你可能感兴趣的:(spring,boot)