velocity

velocity分页模板

不想你离开。 提交于 2020-02-20 14:10:53
以前用后台java拼接分页代码,不利于修改。找到一份velocity模板。 1 <!-- 分页模板 --> 2 #macro(pager $url $pager) 3 <url class="page"> 4 #set($FRONT_LEN = 3) 5 #set($BEHIND_LEN = 3) 6 #set($PAGER_LEN = 7) 7 #set($last = $!{pager.pageNumber} - 1) 8 #set($next = $!{pager.pageNumber} + 1) 9 <!--设置页码列表开始和结束 --> 10 <!--如果总页数<=展示长度 --> 11 #if($!{pager.totalPage} <= $!{PAGER_LEN}) 12 #set($header = 1) 13 #set($ender = $!{pager.totalPage}) 14 <!--如果总页数>展示长度 --> 15 #else 16 <!-- 当前页 < 展示长度--> 17 #if($!{pager.pageNumber} < $!{PAGER_LEN}) 18 #set($header = 1) 19 #set($ender = $PAGER_LEN) 20 <!--当前页 >= 展示长度 && 定尾部,再定头部 --> 21 #else 22

Velocity基本常用语法

≯℡__Kan透↙ 提交于 2020-02-14 00:13:38
Velocity是一个基于java的模板引擎(template engine),它允许任何人仅仅简单的使用模板语言(template language)来引用由java代码定义的对象。作为一个比较完善的模板引擎,Velocity的功能是比较强大的,但强大的同时也增加了应用复杂性。 一、基本语法 1、"#"用来标识Velocity的脚本语句,包括#set、#if 、#else、#end、#foreach、#end、#iinclude、#parse、#macro等; 如: #if($info.imgs) <img src="$info.imgs" border=0> #else <img src="noPhoto.jpg"> #end 2、"$"用来标识一个对象(或理解为变量);如 如:$i、$msg、$TagUtil.options(...)等。 3、"{}"用来明确标识Velocity变量; 比如在页面中,页面中有一个$someonename,此时,Velocity将把someonename作为变量名,若我们程序是想在someone这个变量的后面紧接着显示name字符,则上面的标签应该改成${someone}name。 4、"!"用来强制把不存在的变量显示为空白。 如当页面中包含$msg,如果msg对象有值,将显示msg的值,如果不存在msg对象同,则在页面中将显示$msg字符

Velocity模板引擎

我与影子孤独终老i 提交于 2020-02-04 11:16:07
1.Velocity模板引擎 1.1.简介 Velocity是一个 基于Java的 模板引擎框架,提供的模板语言可以使用在Java中定义的对象和变量上。Velocity是Apache基金会的项目,开发的目标是分离MVC模式中的持久化层和业务层。 1.2.使用场景 开发Velocity的目标是分离 MVC 模式中的持久化层和业务层。但是在实际应用过程中,Velocity 不仅仅被用在了 MVC 的架构中,还可以被用在以下一些场景中: Web应用 :开发者在不使用JSP的情况下,可以 用Velocity让HTML具有动态内容的特性 源代码生成 : Velocity可以被用来生成Java代码 、SQL或者PostScript,有很多开源和商业开发的软件是使用Velocity来开发的 自动Email :很多软件的用户注册、密码提醒或者报表都是使用Velocity来自动生成的,使用 Velocity可以在文本文件里面生成邮件内容,而不是在Java代码中拼接字符串 转换XML :Velocity提供一个叫Anakia的ant任务,可以读取XML文件并让它能够被Velocity 模板读取。一个比较普遍的应用是将xdoc文档转换成带样式的HTML文件 2.基本语法 2.1.注释 单行:## 句子 多行:#* 句子句子 *# 文档格式:#** 句子句子 **# 2.2.变量定义 #set($name

Apache Velocity can not Initialize

有些话、适合烂在心里 提交于 2020-02-04 03:23:33
问题 When i try to initialize velocity engine using VelocityEngine engine = new VelocityEngine(); engine.init(); I encounter the same error when i try Velocity.init(); org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.ServletLogChute with the current runtime configuration. What may cause this exception? 回答1: try something like this: Properties p = new Properties(); p.setProperty("resource.loader", "class"); p.setProperty("class

Using Velocity Tools with Spring 3.0.3

北战南征 提交于 2020-01-23 06:48:45
问题 When I update the bean: <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> <property name="cache" value="true"/> <property name="prefix" value=""/> <property name="suffix" value=".vm"/> <property name="toolboxConfigLocation" value="tools.xml" /> </bean> With the tools.xml path for Velocity Tools, I get: Caused by: java.lang.ClassNotFoundException: org.apache.velocity.tools.view.ToolboxManager I've tried plugging in tools version 2 and 1.4,

Using Velocity Tools with Spring 3.0.3

痴心易碎 提交于 2020-01-23 06:48:37
问题 When I update the bean: <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> <property name="cache" value="true"/> <property name="prefix" value=""/> <property name="suffix" value=".vm"/> <property name="toolboxConfigLocation" value="tools.xml" /> </bean> With the tools.xml path for Velocity Tools, I get: Caused by: java.lang.ClassNotFoundException: org.apache.velocity.tools.view.ToolboxManager I've tried plugging in tools version 2 and 1.4,

互动编程习作——表现随机行为及牛顿运动学

感情迁移 提交于 2020-01-23 04:45:08
第一章 随机游走与概率分布 以上所有素材都取自这里! 为了实现随机游走,我采用了: rect(0,0,width,height); position.add(velocity); ellipse(mouseX,mouseY,16,16); 生成一个随鼠标移动的球体,并在背景板留下轨迹。 生成一个在不间断运动的球体: if ((position.x > width) || (position.x < 0)) { velocity.x = velocity.x * -1; } if ((position.y > height) || (position.y < 0)) { velocity.y = velocity.y * -1; } 运动规律是按照速度前进,遇到边界则改变速度方向。 为了使运动的物体和鼠标交互,我采用: if ((mouseX > position.x) && velocity.x<=0) { velocity.x = velocity.x * -1; } if ((mouseX < position.x) && velocity.x>=0) { velocity.x = velocity.x * -1; } 让物体根据鼠标的位置移动,向鼠标靠拢。 效果如图: 第二章 Processing中的向量。 我模拟的中心是一个带磁性的球体,无数的小铁球靠近磁体: 引用了两个类

Hexo-Next提高加载速度

自古美人都是妖i 提交于 2020-01-21 16:45:34
Hexo作为纯静态博客最大的优点就是快,但要真正的快起来你可能需要做这些事情。 CDN加速 这里只是针对第三方静态文件的加速,修改 Next 主题配置文件 _config.yml 如下: #! --------------------------------------------------------------- #! DO NOT EDIT THE FOLLOWING SETTINGS #! UNLESS YOU KNOW WHAT YOU ARE DOING #! See: https://theme-next.org/docs/advanced-settings #! --------------------------------------------------------------- # Script Vendors. Set a CDN address for the vendor you want to customize. # Be aware that you would better use the same version as internal ones to avoid potential problems. # Remember to use the https protocol of CDN files when you enable

Is there way to use apache velocity template file with any HTML templating engine like mustache or handlebar.js

孤者浪人 提交于 2020-01-17 12:15:25
问题 Is there any template engine js library available by which i can use apache velocity template file to generate HTML? 回答1: I didn't find any JS library which could use apache velocity templates to produce HTML. However, we did find a NPM which could be used to generate HTML page using apache velocity template. Here is URL => Velocity NPM 来源: https://stackoverflow.com/questions/29563833/is-there-way-to-use-apache-velocity-template-file-with-any-html-templating-engin

Liferay velocity template showing only first image for repeatable image field

纵饮孤独 提交于 2020-01-17 04:59:26
问题 I have created structures and template for adding the events. The input I have taken is: year with month, image for the event, description for the event. All the data is displaying properly except image. The image which I have given first is displaying for each event. Can any one help me? <root available-locales="en_US" default-locale="en_US"> <dynamic-element dataType="html" fieldNamespace="ddm" indexType="keyword" name="about_fe" readOnly="false" repeatable="false" required="false"