zoukankan      html  css  js  c++  java
  • Spring整合Velocity模版引擎

    1. 首先通过pom.xml自动加载velocity扩展包到工程:

    1 <dependency>
    2     <groupId>velocity</groupId>
    3     <artifactId>velocity</artifactId>
    4     <version>1.5</version>
    5 </dependency>

    2. 然后在自动装载bean的xml里边添加如下配置:

     1 <bean id="velocityConfig"
     2     class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
     3     <property name="resourceLoaderPath" value="/WEB-INF/views/" />
     4     <property name="velocityPropertiesMap">
     5         <props>
     6             <prop key="input.encoding">utf-8</prop>
     7             <prop key="output.encoding">utf-8</prop>
     8         </props>
     9     </property>
    10 </bean>
    11 <bean id="viewResolver"
    12     class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
    13     <property name="cache" value="true" />
    14     <property name="exposeSpringMacroHelpers" value="true" />
    15     <property name="suffix" value=".vm" />
    16     <property name="contentType" value="text/html;charset=UTF-8" />
    17 </bean>

    通过如上配置,Spring工程就支持Velocity模版引擎了,模版文件位于:/WEB-INF/views/目录下,指定输入和输出编码为UTF-8编码,同时指定了模版的后缀名称为.vm结尾。

  • 相关阅读:
    linux_crontab_定时删除
    bigdata_zookeeper 可视化界面zkui
    bigdata_ Kafka集群模式部署
    大数据_zookeeper环境搭建中的几个坑
    实战-130W表增加字段耗时
    每天一个linux命令
    nginx重启报找不到nginx.pid的解决方法
    log4j配置
    mysql select 1
    查看mysql语句运行时间
  • 原文地址:https://www.cnblogs.com/liuriqi/p/4039201.html
Copyright © 2011-2022 走看看