Can anyone please show me hello world example for springmavc with freemarker. I googled number of sites even freemarker site but did not find any useful that shows how to use freemarker with springmvc. So please can any one write a hello world type simple program to show how to use freemarker with springmvc or suggest me some website where I can find psringmvc and freemarker configurations 开发者_StackOverflow中文版from scratch.
I know it is too basic to ask but hope you me.
Thanks
This is covered in the Spring documentation for both Velocity and Freemarker. You need to set-up a FreeMarkerConfigurer bean and a FreeMarkerViewResolver, and that's about it.
<!-- freemarker config -->
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/freemarker/"/>
</bean>
<!--
View resolvers can also be configured with ResourceBundles or XML files. If you need
different view resolving based on Locale, you have to use the resource bundle resolver.
-->
<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="cache" value="true"/>
<property name="prefix" value=""/>
<property name="suffix" value=".ftl"/>
</bean>
精彩评论