开发者

SpringMVC and FreeMarker [closed]

开发者 https://www.devze.com 2023-02-12 03:11 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号