Spring+freemarker

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

Spring+freemarkerSpring+freemarkerSpring+freemarker

<servlet>

<init-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/config.xml</param-value>

</init-param>

,,,,,,

</servlet>

Spring+freemarkerSpring+freemarkerSpring+freemarker

在config.xml 里面的freemarker配置

Spring+freemarkerSpring+freemarkerSpring+freemarker

<beanid="freemarkerConfig"

class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">

<propertyname="templateLoaderPath"value="/WEB-INF/view/"/>

</bean>

<beanid="viewResolver"

class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">

<propertyname="viewClass">

<value>

org.springframework.web.servlet.view.freemarker.FreeMarkerView

</value>

</property>

<propertyname="prefix">

<value>/</value>

</property>

<propertyname="suffix">

<value>.ftl</value>

</property>

</bean>

Spring+freemarkerSpring+freemarkerSpring+freemarker

所有的Freemarker文件都放在/WEB-INF/view/下面

再把Freemarker的jarcopy到/WEB--INF/lib下面,就OK了

相关推荐