feat: freemaker 설정 remark
parent
b09c771bf2
commit
a59fa237d5
@ -0,0 +1,65 @@
|
||||
package kr.xit.framework.support.freemaker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.tiles.TilesContainer;
|
||||
import org.apache.tiles.evaluator.AttributeEvaluatorFactory;
|
||||
import org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory;
|
||||
import org.apache.tiles.extras.complete.CompleteAutoloadTilesInitializer;
|
||||
import org.apache.tiles.factory.AbstractTilesContainerFactory;
|
||||
import org.apache.tiles.request.ApplicationContext;
|
||||
import org.apache.tiles.request.ApplicationResource;
|
||||
import org.apache.tiles.request.freemarker.render.FreemarkerRendererBuilder;
|
||||
import org.apache.tiles.request.render.BasicRendererFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.view.UrlBasedViewResolver;
|
||||
import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
|
||||
|
||||
//@Configuration
|
||||
public class FreeMarkerConfig{
|
||||
|
||||
@Bean
|
||||
public TilesConfigurer tilesConfigurer() {
|
||||
|
||||
String tilesDefinitionPath = "classpath*:/WEB-INF/freemarker/layout-definition/tiles-layout.xml";
|
||||
|
||||
TilesConfigurer tilesConfigurer = new TilesConfigurer();
|
||||
tilesConfigurer.setTilesInitializer(new CompleteAutoloadTilesInitializer() {
|
||||
@Override
|
||||
protected AbstractTilesContainerFactory createContainerFactory(ApplicationContext context) {
|
||||
// BasicTilesContainerFactory
|
||||
return new CompleteAutoloadTilesContainerFactory() {
|
||||
@Override
|
||||
protected List<ApplicationResource> getSources(ApplicationContext applicationContext) {
|
||||
List<ApplicationResource> retValue = new ArrayList<ApplicationResource>(1);
|
||||
retValue.add(applicationContext.getResource(tilesDefinitionPath));
|
||||
return retValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerAttributeRenderers(BasicRendererFactory rendererFactory, ApplicationContext applicationContext, TilesContainer container, AttributeEvaluatorFactory attributeEvaluatorFactory) {
|
||||
super.registerAttributeRenderers(rendererFactory, applicationContext, container, attributeEvaluatorFactory);
|
||||
FreemarkerRendererBuilder freemarkerRenderer = FreemarkerRendererBuilder.createInstance();
|
||||
freemarkerRenderer.setApplicationContext(applicationContext);
|
||||
freemarkerRenderer.setParameter("defaultEncoding", "UTF-8");
|
||||
//freemarkerRenderer.setParameter("ClasspathTlds", "/META-INF/tld/tiles-jsp.tld, /META-INF/spring.tld");
|
||||
//freemarkerRenderer.setParameter("autoInclude", "/WEB-INF/freemarker/common/common.ftl");
|
||||
freemarkerRenderer.setParameter("NoCache", "true");
|
||||
rendererFactory.registerRenderer("freemarker", freemarkerRenderer.build());
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
return tilesConfigurer;
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public UrlBasedViewResolver tilesViewResolver() {
|
||||
// UrlBasedViewResolver urlBasedViewResolver = new UrlBasedViewResolver();
|
||||
// urlBasedViewResolver.setViewClass(TilesView.class);
|
||||
// urlBasedViewResolver.setRequestContextAttribute("rc");
|
||||
// return urlBasedViewResolver;
|
||||
// }
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
|
||||
|
||||
|
||||
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
|
||||
<property name="templateLoaderPath" value="/WEB-INF/ftl"/>
|
||||
<property name="defaultEncoding" value="UTF-8"/>
|
||||
<property name="DEFAULT_INCOMPATIBLE_IMPROVEMENTS" value="2.3.23"/>
|
||||
<property name="freemarkerSettings">
|
||||
<map>
|
||||
<entry key="template_update_delay" value="60000"/>
|
||||
<entry key="auto_flush" value="false"/>
|
||||
<entry key="default_encoding" value="UTF-8"/>
|
||||
<entry key="whitespace_stripping" value="true"/>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
@ -0,0 +1,10 @@
|
||||
<#ftl encoding="utf-8"/>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>네이바 프리마카</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>컨트롤러의 메세지: ${message}</h1>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue