zoukankan      html  css  js  c++  java
  • 【开发笔记】- SSM使用velocity模板语言

    1、在pom.xml里添加velocity模板语言支持的依赖

    <!-- velocity模板语言支持包 -->
    <dependency>
      <groupId>org.apache.velocity</groupId>
       <artifactId>velocity</artifactId>
       <version>1.7</version>
    </dependency>
    <!-- velocity-tools -->
    <dependency>
      <groupId>org.apache.velocity</groupId>
      <artifactId>velocity-tools</artifactId>
      <version>2.0</version>
    </dependency>

    2、spring-mvc.xml中配置velocity

    <!--velocity配置-->
    <bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
      <property name="resourceLoaderPath" value="/WEB-INF/views"/>
      <property name="velocityProperties">
      <props>
        <prop key="input.encoding">utf-8</prop>
        <prop key="output.encoding">utf-8</prop>
        <prop key="file.resource.loader.cache">false</prop>
        <prop key="file.resource.loader.modificationCheckInterval">1</prop>
        <prop key="velocimacro.library.autoreload">false</prop>
      </props>
      </property>
    </bean>
    
    <!--velocity模板语言-->
    <bean class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
      <property name="suffix" value=".vm"/>
      <property name="contentType" value="text/html;charset=utf-8"/>
      <property name="dateToolAttribute" value="date"/><!--日期函数名称-->
    </bean>

    3、新建页面 .vm 后缀的文件

  • 相关阅读:
    springboot 整合Elasticsearch
    SpringBoot 使用AOP记录接口访问日志
    Java8 Collectors类的静态工厂方法
    Java8 Stream流方法
    Java8 Lambda表达式
    Java通过行为参数化传递代码
    springboot使用SpringTask实现定时任务
    Cron表达式
    springboot整合swagger-ui
    springboot整合redis
  • 原文地址:https://www.cnblogs.com/juihai/p/10307780.html
Copyright © 2011-2022 走看看