Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have used freemarker in a spring-mvc demo webapp (spring 3.0.5). See <a href="http://projectnotes.svn.sourceforge.net/viewvc/projectnotes/trunk/" rel="nofollow">http://projectnotes.svn.sourceforge.net/viewvc/projectnotes/trunk/</a> 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</p> <pre><code>@Controller public class IndexController { @RequestMapping("/index.html") public String index(Map&lt;String, Object&gt; model) { // populate the model parameter if you need it in index.ftl return "index"; } } </code></pre> <p>My freemarker context file looks like this</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;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-2.5.xsd" default-autowire="byName"&gt; &lt;bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape"/&gt; &lt;bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"&gt; &lt;property name="templateLoaderPath"&gt; &lt;value&gt;/WEB-INF/freemarker/&lt;/value&gt; &lt;/property&gt; &lt;property name="freemarkerVariables"&gt; &lt;map&gt; &lt;entry key="xml_escape" value-ref="fmXmlEscape"/&gt; &lt;/map&gt; &lt;/property&gt; &lt;property name="freemarkerSettings"&gt; &lt;props&gt; &lt;prop key="template_update_delay"&gt;3&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"&gt; &lt;property name="cache" value="true"/&gt; &lt;property name="prefix" value=""/&gt; &lt;property name="suffix" value=".ftl"/&gt; &lt;property name="exposeSpringMacroHelpers" value="true"/&gt; &lt;property name="exposeRequestAttributes" value="true"/&gt; &lt;property name="exposeSessionAttributes" value="true"/&gt; &lt;/bean&gt; &lt;bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"&gt; &lt;property name="mediaTypes"&gt; &lt;map&gt; &lt;entry key="html" value="text/html"/&gt; &lt;entry key="ftl" value="text/html"/&gt; &lt;entry key="xml" value="application/xml"/&gt; &lt;entry key="json" value="application/json"/&gt; &lt;/map&gt; &lt;/property&gt; &lt;property name="favorPathExtension" value="true"/&gt; &lt;property name="defaultViews"&gt; &lt;list&gt; &lt;bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"&gt; &lt;!-- prevents code injection --&gt; &lt;property name="prefixJson" value="true"/&gt; &lt;/bean&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="viewResolvers"&gt; &lt;list&gt; &lt;bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"&gt; &lt;property name="cache" value="true" /&gt; &lt;property name="order" value="1"/&gt; &lt;property name="prefix" value="/" /&gt; &lt;property name="suffix" value=".ftl" /&gt; &lt;property name="contentType" value="text/html;charset=UTF-8"/&gt; &lt;property name="exposeSpringMacroHelpers" value="true" /&gt; &lt;property name="requestContextAttribute" value="rc" /&gt; &lt;property name="exposeSessionAttributes" value="true" /&gt; &lt;/bean&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload