Spring+freemarker

Spring支持多种View, 因为一直以来用OFBiz, OFBiz缺省用的Freemarker, 已经很熟悉了, 所以今天学习一下Spring+FreeMarker的配置

web.xml中我配置了


< servlet >

< init - param >
< param - name > contextConfigLocation </ param - name >
< param - value >/ WEB - INF / config.xml </ param - value >
</ init - param >
,,,,,,
</ servlet >



在config.xml 里面的freemarker配置


< bean id = " freemarkerConfig "
class = " org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer " >
< property name = " templateLoaderPath " value = " /WEB-INF/view/ " />
</ bean >
< bean id = " viewResolver "
class = " org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver " >
< property name = " viewClass " >
< value >
org.springframework.web.servlet.view.freemarker.FreeMarkerView
</ value >
</ property >
< property name = " prefix " >
< value >/</ value >
</ property >
< property name = " suffix " >
< value > .ftl </ value >
</ property >
</ bean >

所有的Freemarker文件都放在/WEB-INF/view/下面
再把Freemarker的jar copy到/WEB--INF/lib下面, 就OK了

你可能感兴趣的:(freemarker)