Server/Spring Boot
spring boot // 머스태치 html확장자로 이용하기
Jaybon
2020. 8. 11. 16:32
머스태치 html확장자로 이용하기
컨피그를 어노테이션 하고
configureViewResolvers를 오버라이딩
package com.jaybon.securityEx01.config;
import org.springframework.boot.web.servlet.view.MustacheViewResolver;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer{
@Override // 뷰리졸버 설정
public void configureViewResolvers(ViewResolverRegistry registry) {
// 머스태치 리졸버 설정
MustacheViewResolver resolver = new MustacheViewResolver();
resolver.setCharset("utf-8");
resolver.setContentType("text/html;charset=utf-8");
resolver.setPrefix("classpath:/templates/"); // 뷰의 위치
resolver.setSuffix(".html");
registry.viewResolver(resolver);
}
}
---------------------------------