So I have Index action in my HomeController.java class.
I have my freemarker templates in:
/web-inf/ftl/test.ftl
How can I load the template?
I have this in my appname-servlet.xml:
<bean id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="suffix">
<value>.ftl</value>
</property>
</bean>
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/freemarker/"/>
</bean>
What should my action code look like for HomeController index action?
I have /web-inf/freemarker/index.ftl
From an operational example available on my blog, your controller should look something like this:
I have used freemarker in a spring-mvc demo webapp (spring 3.0.5). See http://projectnotes.svn.sourceforge.net/viewvc/projectnotes/trunk/ The web controller looks like this, so your index.ftl (which you would put under src/main/webapp/WEB-INF) would be rendered when a request is made to index.html
My freemarker context file looks like this