1.jsp
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/template/" />
<property name="suffix" value=".jsp" />
</bean>
2.Velocity
<bean id="velocityConfigurer"
class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<!-- resourceLoaderPath属性通知Velocity到哪里找到velocity模板 -->
<property name="resourceLoaderPath" value="/WEB-INF/template/" />
<!-- 处理中文 -->
<property name="velocityProperties">
<props>
<prop key="input.encoding">gbk</prop>
<prop key="output.encoding">gbk</prop>
</props>
</property>
</bean>
<!-- 配置velocity视图解析器 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<!-- 配置模板的后缀 -->
<property name="prefix" value="/" />
<property name="suffix" value=".vm" />
<!-- 处理中文乱码 -->
<property name="contentType" value="text/html;charset=gbk" />
</bean>
3.Freemarker
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/ftltemplate/" />
<property name="freemarkerSettings">
<props>
<prop key="date_format">yyyy-MM-dd </prop>
<prop key="time_format">HH:mm:ss</prop>
<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
<prop key="number_format">0.######</prop>
<prop key="defaultEncoding">GBK</prop>
<prop key="url_escaping_charset">GBK</prop>
<prop key="locale">zh_CN</prop>
<prop key="template_update_delay">0</prop>
</props>
</property>
<property name="freemarkerVariables">
<map>
<entry key="xml_escape" value-ref="fmXmlEscape" />
</map>
</property>
</bean>
<bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="exposeSpringMacroHelpers" value="true" />
<property name="requestContextAttribute" value="rc" />
<property name="prefix" value="/" />
<property name="suffix" value=".ftl" />
<property name="contentType" value="text/html;charset=GBK"></property>
</bean>
4.HTML5 模版引擎 Thymeleaf
<bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/WEB-INF/thymleafTemplates/" />
<property name="suffix" value=".html"/>
<property name="templateMode" value="HTML5"/>
</bean>
<bean id="templateEngine" class="org.thymeleaf.spring3.SpringThymeleafTemplateEngine">
<property name="templateResolver" ref="templateResolver"/>
</bean>
<bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine"/>
</bean>