velocity

Replacing variables in a word document template with java

自古美人都是妖i 提交于 2019-11-27 10:11:16
问题 I want to load a template word document to add content to and save as new document. I'm working on .doc file. After a long research I only found solutions for docx : http://www.smartjava.org/content/create-complex-word-docx-documents-programatically-docx4j http://www.sambhashanam.com/mail-merge-in-java-for-microsoft-word-document-part-i/ So I want to replace any variable written in this format: $VAR by its value. Can I do it with velocity or Apache-poi, what is the best solution for it. Any

教育

这一生的挚爱 提交于 2019-11-27 09:49:43
创建父工程guli-parent 在项目guli下创建模块:使用 Spring Initializr 快速初始化一个 Spring Boot 模块,版本:2.0.7.RELEASE 配置 pom.xml (修改版本为 :2.0.7.RELEASE <artifactId> 节点后面添加 <packaging>pom</packaging> spring-boot-starter 改成 spring-boot-starter-web) <properties> <java.version>1.8</java.version> <guli.version>0.0.1-SNAPSHOT</guli.version> <mybatis-plus.version>3.0.5</mybatis-plus.version> <velocity.version>2.0</velocity.version> <swagger.version>2.7.0</swagger.version> </properties>替换 <java.version>1.8</java.version> <dependencyManagement> <dependencies> <!--mybatis-plus 持久层--> <dependency> <groupId>com.baomidou</groupId>

Why would I use a templating engine? jsp include and jstl vs tiles, freemarker, velocity, sitemesh

佐手、 提交于 2019-11-27 09:02:44
问题 I'm about to choose to way to organize my view (with spring-mvc, but that shouldn't matter much) There are 6 options as far as I see (though they are not mutually exclusive): Tiles Sitemesh Freemarker Velocity <jsp:include> <%@ include file=".."> Tiles and Sitemesh can be grouped; so can Freemarker and Velocity . Which one within each group to use is not a matter of this discussion, there are enough questions and discussions about it. This is an interesting read, but can't quite convince me

Could not find org.springframework.boot:spring-boot-starter-velocity

让人想犯罪 __ 提交于 2019-11-27 08:16:50
问题 I'm new to spring and trying to use velocity with spring boot. Here is my build.gradle repositories { mavenCentral() } plugins { id 'org.springframework.boot' version '2.0.4.RELEASE' } apply plugin: 'java' apply plugin: 'eclipse-wtp' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'war' dependencies { compile('org.springframework.boot:spring-boot-starter-web') compile('org.springframework.boot:spring-boot-starter-velocity') runtime('org

Velocity Template engine - key-value-map

对着背影说爱祢 提交于 2019-11-27 07:47:32
问题 I have some problems wo use a key-value-map into Velocity. Someone has an example of this functionality? $myMap ={} $myMap.put("mykey1", "myvalue") $myMap.delete("mykey1") $myMap.getValue("mykey1") 回答1: As Nathan said, you should use: #set ($myMap = {}) to create a new map and assign it to a variable. Now, why is the put call printed. Anything that is not inside a directive, like #set(not printed) or #if(not printed) or #foreach(again not printed) , is printed, including free text, variables,

Springboot集成velocity

♀尐吖头ヾ 提交于 2019-11-27 07:11:44
1.加入maven包 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> 2.velocity配置 spring.velocity.cache= false spring.velocity.charset=UTF-8 spring.velocity.check-template-location=true spring.velocity.content-type=text/html spring.velocity.enabled=true spring.velocity.resource-loader-path=/templates spring.velocity.prefix=/templates/ spring.velocity.suffix=.vm 3.测试页面 index.vm <html> <body> 亲爱的${toUserName},你好! ${message} 祝:开心! ${fromUserName}55 $

Velocity教程

∥☆過路亽.° 提交于 2019-11-27 07:09:45
1.什么是Velocity Velocity是一个基于Java的模板引擎,通过特定的语法,Velocity可以获取在java语言中定义的对象,从而实现界面和java代码的真正分离,这意味着可以使用velocity替代jsp的开发模式了(实际上笔者所在的公司已经这么做了)。这使得前端开发人员可以和 Java 程序开发人员同步开发一个遵循 MVC 架构的 web 站点,在实际应用中,velocity还可以应用于很多其他的场景. 2.velocity介绍 Velocity是一个基于Java的模板引擎,其提供了一个Context容器,在java代码里面我们可以往容器中存值,然后在vm文件中使用特定的语法获取,这是velocity基本的用法,其与jsp、freemarker并称为三大视图展现技术,相对于jsp而言,velocity对前后端的分离更加彻底:在vm文件中不允许出现java代码,而jsp文件中却可以. 3.velocity的基本用法 在这里我们以一个HelloVelocity作为Velocity的入门实例.首先在 官网 下载velocity的最新发布包,新建普通java项目,引入其中的velocity-1.7.jar和lib文件夹下的所有jar包即可. 然后分为如下两步。 4.velocity变量 在Velocity中也有变量的概念, 使用$符声明变量

关于Thymeleaf是Spring Boot 推荐的模板谣言

前提是你 提交于 2019-11-27 05:44:49
国内早已经流传Thymeleaf是Spring Boot推荐的模板引擎,这个毫无根据,我发现官网文档并没有这个说法(官网版本是Spring Boot 2.1),截图如下 如果你看Spring Boot 关于JSon的使用,则明显说明了Spring Boot 推荐JackSon Thymeleaf在很长时间都因为难用的语法,高成本的学习曲线,以及惨目忍睹的性能而被世界开发人员排斥,3.0以来性能有了提高(然而还是很差),且集成Spring的很多特性,所以得到Spring Boot 作为可选模板引擎之一推荐。Spring Boot没有使用Velocity,这是因为Velocity不行吗?当然不是. Spring Boot 作为一个技术框架,跟我们普通架构师做技术选型一样,也面临很多选择考虑,在我看来,Spring Boot的选型或者是推荐并不一定是最优的,比如 Spring Boot 2 使用JDK自带的HttpURLConnection实现Rest调用,而高效和功能齐全的OKHttp 并没有被默认使用,Spring Boot 源码日志使用 Commons Logging接口(尽管使用了Logback作为实现),但我们都知道SLF4J的API接口使用起来更舒服 关于Thymeleaf是Spring Boot 推荐的模板,这个是培训机构新造出来的一个培训热点而已,因为他确实难以掌握,哈哈

VelocityTracker 使用

风格不统一 提交于 2019-11-27 05:40:08
这个类的话是用来得到手势在屏幕上滑动的速度,也许我们用的比较少,但是还是在这里写下怎样使用VelocityTracker这个类, 第一步的话,当然是得到该类的一个实例 mVelocityTracker = VelocityTracker.obtain(); 第二步,需要告诉mVelocityTracker 这个对象你要对那个MotionEvent 进行监控(也就是说得到在那个MotionEvent 上的速度) 对于MotionEvent 的解释文档是这么说的 { 对象,用于 报告 运动 (鼠标, 笔, 手指 ,轨迹球 ) 事件 。 这个类 可能持有 绝对或相对 运动} 使用 mVelocityTracker.addMovement(ev); 方法来制定一个MotionEvent。 第三步, 这一步就相当简单了直接用 mVelocityTracker.getXVelocity(); 方法获取在水平方向上滑动的速度 用 mVelocityTracker.getYVelocity(); 方法就可以获取垂直方向上滑动的速度了。 最后的话我附上一个完整的例子让大家看的更明白点吧! VelocityTracker mVelocityTracker = VelocityTracker.obtain(); mVelocityTracker.addMovement(ev); if (ev

Calling class methods (static) from inside a velocity view page

二次信任 提交于 2019-11-27 03:50:07
问题 Can you call class methods from inside a view page? Specifically ones that are not passed into the view? In asp.net MVC I can do this: <%= SomeClass.FixDateFormat(ViewData.Model.SomeClass.DateCreated) %> 回答1: Since this came up in the top of my google search on this topic it seems like folks might like to see an updated answer when they get this on the top of their search... (found this here: http://velocity.10973.n7.nabble.com/Use-of-static-functions-td15126.html) in Velocity 1.5 or earlier,